Fix Stock
This commit is contained in:
parent
4372101d35
commit
9ebaeec5c0
|
@ -9,6 +9,7 @@ from . import purchase
|
|||
from . import sale
|
||||
from . import product
|
||||
from . import production
|
||||
from . import stock
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -25,8 +26,8 @@ def register():
|
|||
quality.ProductSpecies,
|
||||
quality.ICACertificate,
|
||||
quality.PhytosanitaryCertificate,
|
||||
quality.StockMove,
|
||||
quality.ShipmentIn,
|
||||
stock.StockMove,
|
||||
stock.ShipmentIn,
|
||||
purchase.Purchase,
|
||||
purchase.PurchaseLine,
|
||||
purchase.PurchaseFarmingStart,
|
||||
|
|
34
quality.py
34
quality.py
|
@ -90,31 +90,6 @@ class ICACertificate(ModelSQL, ModelView):
|
|||
return '[' + self.number + '] ' + self.farm
|
||||
|
||||
|
||||
class StockMove(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
STATES = {
|
||||
'invisible': ~Eval('farming'),
|
||||
}
|
||||
farming = fields.Boolean('Farming')
|
||||
original_qty = fields.Float('Qty Original', states=STATES)
|
||||
quality_analysis = fields.One2Many('farming.quality.analysis', 'origin',
|
||||
'Quality Analysis', states=STATES)
|
||||
qty_checked = fields.Float('Qty Checked', states=STATES)
|
||||
returned_qty = fields.Function(fields.Float('Returned Qty',
|
||||
states=STATES), 'get_returned_qty')
|
||||
|
||||
@fields.depends('farming', 'original_qty', 'quantity')
|
||||
def on_change_farming(self):
|
||||
if self.farming and self.quantity:
|
||||
self.original_qty = self.quantity
|
||||
|
||||
def get_returned_qty(self, name=None):
|
||||
res = []
|
||||
for qa in self.quality_analysis:
|
||||
res.append(qa.returned_qty)
|
||||
return sum(res)
|
||||
|
||||
|
||||
class PhytosanitaryCertificate(ModelSQL, ModelView):
|
||||
"Phytosanitary Certificate"
|
||||
__name__ = "farming.certificate.phyto"
|
||||
|
@ -134,12 +109,3 @@ class PhytosanitaryCertificate(ModelSQL, ModelView):
|
|||
|
||||
def get_rec_name(self, name):
|
||||
return '[' + self.number + '] ' + self.party.name
|
||||
|
||||
|
||||
class ShipmentIn(metaclass=PoolMeta):
|
||||
'Shipment In'
|
||||
__name__ = 'stock.shipment.in'
|
||||
phyto_certificate = fields.Many2One('farming.certificate.phyto', 'Phyto',
|
||||
domain=[
|
||||
('party', '=', Eval('supplier'))
|
||||
])
|
||||
|
|
11
quality.xml
11
quality.xml
|
@ -162,16 +162,5 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="perm_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="move_view_form">
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit" ref="stock.move_view_form"/>
|
||||
<field name="name">stock_move_view_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="shipment_in_view_form">
|
||||
<field name="model">stock.shipment.in</field>
|
||||
<field name="inherit" ref="stock.shipment_in_view_form"/>
|
||||
<field name="name">shipment_in_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
4
sale.py
4
sale.py
|
@ -68,13 +68,13 @@ class Sale(metaclass=PoolMeta):
|
|||
'to_location': sale.warehouse.production_location.id,
|
||||
}
|
||||
if line.product.producible:
|
||||
input['production'] = cls._get_productions(kit, sale, line)
|
||||
input['production'] = cls._get_production(kit, sale, line)
|
||||
_inputs.append(input)
|
||||
data['inputs'] = [('create', _inputs)]
|
||||
Production.create([data])
|
||||
|
||||
@classmethod
|
||||
def _get_productions(cls, kit, sale, line):
|
||||
def _get_production(cls, kit, sale, line):
|
||||
data = {
|
||||
'reference': sale.reference,
|
||||
# 'customer': '',
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
|
||||
class StockMove(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
STATES = {
|
||||
'invisible': ~Eval('farming'),
|
||||
}
|
||||
farming = fields.Boolean('Farming')
|
||||
original_qty = fields.Float('Qty Original', states=STATES)
|
||||
quality_analysis = fields.One2Many('farming.quality.analysis', 'origin',
|
||||
'Quality Analysis', states=STATES)
|
||||
qty_checked = fields.Float('Qty Checked', states=STATES)
|
||||
returned_qty = fields.Function(fields.Float('Returned Qty',
|
||||
states=STATES), 'get_returned_qty')
|
||||
production = fields.Many2One("production", "Production", states={
|
||||
'invisible': ~Eval('origin')
|
||||
})
|
||||
|
||||
@fields.depends('farming', 'original_qty', 'quantity')
|
||||
def on_change_farming(self):
|
||||
if self.farming and self.quantity:
|
||||
self.original_qty = self.quantity
|
||||
|
||||
def get_returned_qty(self, name=None):
|
||||
res = []
|
||||
for qa in self.quality_analysis:
|
||||
res.append(qa.returned_qty)
|
||||
return sum(res)
|
||||
|
||||
|
||||
class ShipmentIn(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.in'
|
||||
phyto_certificate = fields.Many2One('farming.certificate.phyto', 'Phyto',
|
||||
domain=[('party', '=', Eval('supplier'))])
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="move_view_form">
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit" ref="stock.move_view_form"/>
|
||||
<field name="name">stock_move_view_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="shipment_in_view_form">
|
||||
<field name="model">stock.shipment.in</field>
|
||||
<field name="inherit" ref="stock.shipment_in_view_form"/>
|
||||
<field name="name">shipment_in_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -18,4 +18,5 @@ xml:
|
|||
purchase.xml
|
||||
sale.xml
|
||||
product.xml
|
||||
stock.xml
|
||||
production.xml
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name='effective_date']" position="after">
|
||||
<label name="production"/>
|
||||
<field name="production"/>
|
||||
<label name="farming"/>
|
||||
<field name="farming"/>
|
||||
<label name="original_qty"/>
|
||||
|
|
Loading…
Reference in New Issue