Add phyto
This commit is contained in:
parent
c9866369b4
commit
bae2b1444d
|
@ -20,7 +20,9 @@ def register():
|
|||
quality.MoveReturnCause,
|
||||
quality.ProductSpecies,
|
||||
quality.ICACertificate,
|
||||
quality.PhytosanitaryCertificate,
|
||||
quality.StockMove,
|
||||
quality.ShipmentIn,
|
||||
purchase.Purchase,
|
||||
purchase.PurchaseLine,
|
||||
module='farming', type_='model')
|
||||
|
|
|
@ -24,9 +24,11 @@ class Purchase(metaclass=PoolMeta):
|
|||
@fields.depends('ica_certicate')
|
||||
def on_change_ica_certicate(self):
|
||||
if self.ica_certicate:
|
||||
self.party = self.ica_certicate.party.id
|
||||
if self.party.currency:
|
||||
self.currency = self.party.currency.id
|
||||
party = self.ica_certicate.party
|
||||
self.party = party.id
|
||||
self.invoice_address = party.addresses[0].id
|
||||
if party.currency:
|
||||
self.currency = party.currency.id
|
||||
|
||||
|
||||
class PurchaseLine(metaclass=PoolMeta):
|
||||
|
|
56
quality.py
56
quality.py
|
@ -2,6 +2,7 @@
|
|||
# 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 MoveReturnCause(ModelSQL, ModelView):
|
||||
|
@ -62,16 +63,57 @@ class ICACertificate(ModelSQL, ModelView):
|
|||
|
||||
class StockMove(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
phytosanitary_returned_qty = fields.Float('Phytosanitary Returned Qty')
|
||||
quality_returned_qty = fields.Float('Quality Returned Qty')
|
||||
qty_checked = fields.Float('Qty Checked')
|
||||
STATES = {
|
||||
'invisible': ~Eval('farming'),
|
||||
}
|
||||
farming = fields.Boolean('Farming')
|
||||
original_qty = fields.Float('Qty Original', states=STATES)
|
||||
phytosanitary_returned_qty = fields.Float('Phytosanitary Returned Qty',
|
||||
states=STATES)
|
||||
quality_returned_qty = fields.Float('Quality Returned Qty',
|
||||
states=STATES)
|
||||
qty_checked = fields.Float('Qty Checked', states=STATES)
|
||||
quality_return_cause = fields.Many2One('stock.move.return_cause',
|
||||
'QRC', help="Quality Return Cause", domain=[
|
||||
('kind', '=', 'quality')
|
||||
])
|
||||
], states=STATES)
|
||||
phytosanitary_return_cause = fields.Many2One('stock.move.return_cause',
|
||||
'PRC', help="Phytosanitary Return Cause", domain=[
|
||||
('kind', '=', 'phytosanitary')
|
||||
])
|
||||
original_qty = fields.Float('Qty Original')
|
||||
quality_action = fields.Char('Quality Action')
|
||||
], states=STATES)
|
||||
quality_action = fields.Char('Quality Action', states=STATES)
|
||||
|
||||
@fields.depends('farming', 'original_qty', 'quantity')
|
||||
def on_change_farming(self):
|
||||
if self.farming and self.quantity:
|
||||
self.original_qty = self.quantity
|
||||
|
||||
|
||||
class PhytosanitaryCertificate(ModelSQL, ModelView):
|
||||
"Phytosanitary Certificate"
|
||||
__name__ = "farming.certificate.phyto"
|
||||
number = fields.Char('Number', required=True)
|
||||
party = fields.Many2One('party.party', 'Party', required=True)
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
if clause[1].startswith('!') or clause[1].startswith('not '):
|
||||
bool_op = 'AND'
|
||||
else:
|
||||
bool_op = 'OR'
|
||||
return [bool_op,
|
||||
('number',) + tuple(clause[1:]),
|
||||
('party.name',) + tuple(clause[1:]),
|
||||
]
|
||||
|
||||
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'))
|
||||
])
|
||||
|
|
34
quality.xml
34
quality.xml
|
@ -61,6 +61,34 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="name">product_species_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="farming_certificate_phyto_view_tree">
|
||||
<field name="model">farming.certificate.phyto</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="priority">10</field>
|
||||
<field name="name">certificate_phyto_tree</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="farming_certificate_phyto_view_form">
|
||||
<field name="model">farming.certificate.phyto</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">certificate_phyto_form</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_farming_certificate_phyto_tree">
|
||||
<field name="name">Phytosanitary Certificate</field>
|
||||
<field name="res_model">farming.certificate.phyto</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_farming_certificate_phyto_tree_view1">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view" ref="farming_certificate_phyto_view_tree"/>
|
||||
<field name="act_window" ref="act_farming_certificate_phyto_tree"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_farming_certificate_phyto_tree_view2">
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="view" ref="farming_certificate_phyto_view_form"/>
|
||||
<field name="act_window" ref="act_farming_certificate_phyto_tree"/>
|
||||
</record>
|
||||
<menuitem parent="farming.menu_farming" sequence="2"
|
||||
action="act_farming_certificate_phyto_tree" id="menu_farming_certificate_phyto_tree"/>
|
||||
|
||||
<record model="ir.ui.view" id="farming_quality_ica_view_tree">
|
||||
<field name="model">farming.quality.ica</field>
|
||||
<field name="type">tree</field>
|
||||
|
@ -72,7 +100,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="type">form</field>
|
||||
<field name="name">quality_ica_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_farming_quality_ica_tree">
|
||||
<field name="name">ICA Certificate</field>
|
||||
<field name="res_model">farming.quality.ica</field>
|
||||
|
@ -112,5 +139,10 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<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>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?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. -->
|
||||
<form>
|
||||
<label name="number"/>
|
||||
<field name="number"/>
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
</form>
|
|
@ -0,0 +1,7 @@
|
|||
<?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. -->
|
||||
<tree>
|
||||
<field name="number"/>
|
||||
<field name="party" expand="1"/>
|
||||
</tree>
|
|
@ -0,0 +1,9 @@
|
|||
<?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. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name='company']" position="after">
|
||||
<label name="phyto_certificate"/>
|
||||
<field name="phyto_certificate"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -4,7 +4,9 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<data>
|
||||
<xpath
|
||||
expr="/form/field[@name='effective_date']" position="after">
|
||||
<group col="6" colspan="4" id="quality_analysis" string="Quality Analysis">
|
||||
<label name="farming"/>
|
||||
<field name="farming"/>
|
||||
<group col="8" colspan="4" id="quality_analysis" string="Quality Analysis">
|
||||
<label name="original_qty"/>
|
||||
<field name="original_qty"/>
|
||||
<label name="qty_checked"/>
|
||||
|
@ -18,7 +20,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<label name="quality_returned_qty"/>
|
||||
<field name="quality_returned_qty"/>
|
||||
<label name="quality_action"/>
|
||||
<field name="quality_action"/>
|
||||
<field name="quality_action" colspan="3"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
Loading…
Reference in New Issue