parent
0ec0ad0bc4
commit
1a55571ae0
|
@ -32,6 +32,8 @@ def register():
|
||||||
product.ProductCrop,
|
product.ProductCrop,
|
||||||
product.ProductDO,
|
product.ProductDO,
|
||||||
product.ProductEcological,
|
product.ProductEcological,
|
||||||
|
product.ProductPriceListType,
|
||||||
|
product.PriceList,
|
||||||
product.ProductVariety,
|
product.ProductVariety,
|
||||||
product.Template,
|
product.Template,
|
||||||
weighing.WeighingCenter,
|
weighing.WeighingCenter,
|
||||||
|
|
47
plot.py
47
plot.py
|
@ -4,6 +4,7 @@ from trytond.model import fields, ModelSQL, ModelView
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
class Enclosure(ModelSQL, ModelView):
|
class Enclosure(ModelSQL, ModelView):
|
||||||
"Enclosure"
|
"Enclosure"
|
||||||
|
@ -62,11 +63,13 @@ class Plantation(ModelSQL, ModelView):
|
||||||
"Plantation"
|
"Plantation"
|
||||||
__name__ = 'agronomics.plantation'
|
__name__ = 'agronomics.plantation'
|
||||||
|
|
||||||
code = fields.Char('Code', required=True)
|
code = fields.Char("Code", required=True)
|
||||||
party = fields.Many2One('party.party', 'Party', required=True)
|
party = fields.Many2One('party.party', "Party", required=True)
|
||||||
enclosures = fields.One2Many('agronomics.enclosure', 'plantation',
|
enclosures = fields.One2Many('agronomics.enclosure', 'plantation',
|
||||||
'Enclosure')
|
"Enclosure")
|
||||||
parcels = fields.One2Many('agronomics.parcel', 'plantation', 'Parcel')
|
parcels = fields.One2Many('agronomics.parcel', 'plantation', "Parcel")
|
||||||
|
plantation_year = fields.Integer("Plantation Year")
|
||||||
|
plantation_owner = fields.Many2One('party.party', "Plantation Owner")
|
||||||
|
|
||||||
def get_rec_name(self, name):
|
def get_rec_name(self, name):
|
||||||
if self.code:
|
if self.code:
|
||||||
|
@ -121,20 +124,6 @@ class Parcel(ModelSQL, ModelView):
|
||||||
if self.plantation and self.crop:
|
if self.plantation and self.crop:
|
||||||
return self.plantation.code + ' - ' + self.crop.rec_name
|
return self.plantation.code + ' - ' + self.crop.rec_name
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def validate(cls, records):
|
|
||||||
super().validate(records)
|
|
||||||
cls.check_percent_beneficiaries(records)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def check_percent_beneficiaries(cls, records):
|
|
||||||
for record in records:
|
|
||||||
percent = sum([x.percent for x in record.beneficiaries])
|
|
||||||
if record.beneficiaries and abs(100 - round(percent, 2)) > 0.0001:
|
|
||||||
raise UserError(gettext('agronomics.msg_beneficiaris_percent',
|
|
||||||
crop=record.crop.rec_name,
|
|
||||||
plantation=record.plantation.rec_name))
|
|
||||||
|
|
||||||
def get_all_do(self, name):
|
def get_all_do(self, name):
|
||||||
return ",".join([x.name for x in self.denomination_origin])
|
return ",".join([x.name for x in self.denomination_origin])
|
||||||
|
|
||||||
|
@ -168,7 +157,21 @@ class Beneficiaries(ModelSQL, ModelView):
|
||||||
"Beneficiaries"
|
"Beneficiaries"
|
||||||
__name__ = 'agronomics.beneficiary'
|
__name__ = 'agronomics.beneficiary'
|
||||||
|
|
||||||
party = fields.Many2One('party.party', 'Beneficiary', required=True)
|
party = fields.Many2One('party.party', "Beneficiary", required=True)
|
||||||
percent = fields.Float('Percent', digits=(16, 2), required=True)
|
parcel = fields.Many2One('agronomics.parcel', "Parcel")
|
||||||
parcel = fields.Many2One('agronomics.parcel', 'Parcel')
|
weighing = fields.Many2One('agronomics.weighing', "Weighing")
|
||||||
weighing = fields.Many2One('agronomics.weighing', 'Weighing')
|
product_price_list_type = fields.Many2One('product.price_list.type',
|
||||||
|
"Product Price List Type")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __register__(cls, module_name):
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
table = cls.__table_handler__(module_name)
|
||||||
|
sql_table = cls.__table__()
|
||||||
|
|
||||||
|
# Migration from #047773
|
||||||
|
if table.column_exist('percent'):
|
||||||
|
table.not_null_action('percent', 'remove')
|
||||||
|
table.drop_column('percent')
|
||||||
|
|
||||||
|
super(Beneficiaries, cls).__register__(module_name)
|
||||||
|
|
12
product.py
12
product.py
|
@ -195,3 +195,15 @@ class ProductEcological(ModelSQL):
|
||||||
ondelete='CASCADE', select=True, required=True)
|
ondelete='CASCADE', select=True, required=True)
|
||||||
ecological = fields.Many2One('agronomics.ecological', 'Ecological',
|
ecological = fields.Many2One('agronomics.ecological', 'Ecological',
|
||||||
ondelete='CASCADE', select=True, required=True)
|
ondelete='CASCADE', select=True, required=True)
|
||||||
|
|
||||||
|
|
||||||
|
class ProductPriceListType(ModelSQL, ModelView):
|
||||||
|
"Product Price List Type"
|
||||||
|
__name__ = 'product.price_list.type'
|
||||||
|
name = fields.Char("Name", required=True)
|
||||||
|
|
||||||
|
|
||||||
|
class PriceList(metaclass=PoolMeta):
|
||||||
|
__name__ = 'product.price_list'
|
||||||
|
product_price_list_type = fields.Many2One('product.price_list.type',
|
||||||
|
"Product Price List Type")
|
||||||
|
|
36
product.xml
36
product.xml
|
@ -224,5 +224,41 @@
|
||||||
<field name="perm_create" eval="True"/>
|
<field name="perm_create" eval="True"/>
|
||||||
<field name="perm_delete" eval="True"/>
|
<field name="perm_delete" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- product.price_list.price -->
|
||||||
|
<record model="ir.ui.view" id="product_price_list_type_view_form">
|
||||||
|
<field name="model">product.price_list.type</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">product_price_list_type_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="product_price_list_type_view_tree">
|
||||||
|
<field name="model">product.price_list.type</field>
|
||||||
|
<field name="type">tree</field>
|
||||||
|
<field name="name">product_price_list_type_tree</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.act_window" id="act_product_price_list_type_form">
|
||||||
|
<field name="name">Product Price List Type</field>
|
||||||
|
<field name="res_model">product.price_list.type</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_product_price_list_type_form_view1">
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="view" ref="product_price_list_type_view_tree"/>
|
||||||
|
<field name="act_window" ref="act_product_price_list_type_form"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_product_price_list_type_form_view2">
|
||||||
|
<field name="sequence" eval="20"/>
|
||||||
|
<field name="view" ref="product_price_list_type_view_form"/>
|
||||||
|
<field name="act_window" ref="act_product_price_list_type_form"/>
|
||||||
|
</record>
|
||||||
|
<menuitem parent="product_price_list.menu_price_list" action="act_product_price_list_type_form"
|
||||||
|
id="menu_product_price_list_type_form"/>
|
||||||
|
|
||||||
|
<!-- product.price_list -->
|
||||||
|
<record model="ir.ui.view" id="price_list_view_form">
|
||||||
|
<field name="model">product.price_list</field>
|
||||||
|
<field name="inherit" ref="product_price_list.price_list_view_form"/>
|
||||||
|
<field name="name">price_list_form</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
|
@ -6,6 +6,7 @@ depends:
|
||||||
party
|
party
|
||||||
product_classification
|
product_classification
|
||||||
product_classification_taxonomic
|
product_classification_taxonomic
|
||||||
|
product_price_list
|
||||||
product_template_form_quantity
|
product_template_form_quantity
|
||||||
quality_control
|
quality_control
|
||||||
purchase_contract
|
purchase_contract
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<form>
|
<form>
|
||||||
<label name="party"/>
|
<label name="party"/>
|
||||||
<field name="party"/>
|
<field name="party"/>
|
||||||
<label name="percent"/>
|
<label name="product_price_list_type"/>
|
||||||
<field name="percent"/>
|
<field name="product_price_list_type"/>
|
||||||
<label name="parcel"/>
|
<label name="parcel"/>
|
||||||
<field name="parcel"/>
|
<field name="parcel"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<tree editable="1">
|
<tree editable="1">
|
||||||
<field name="party"/>
|
<field name="party"/>
|
||||||
<field name="percent"/>
|
<field name="product_price_list_type"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<label name="party"/>
|
<label name="party"/>
|
||||||
<field name="party"/>
|
<field name="party"/>
|
||||||
|
<label name="plantation_year"/>
|
||||||
|
<field name="plantation_year"/>
|
||||||
|
<label name="plantation_owner"/>
|
||||||
|
<field name="plantation_owner"/>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="parcels">
|
<page name="parcels">
|
||||||
<field name="parcels" widget="many2many"/>
|
<field name="parcels" widget="many2many"/>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<tree>
|
<tree>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="party"/>
|
<field name="party"/>
|
||||||
|
<field name="plantation_year" tree_invisible="1"/>
|
||||||
|
<field name="plantation_owner" tree_invisible="1"/>
|
||||||
</tree>
|
</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="//field[@name='unit']" position="after">
|
||||||
|
<label name="product_price_list_type"/>
|
||||||
|
<field name="product_price_list_type"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
|
@ -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. -->
|
||||||
|
<form>
|
||||||
|
<label name="name"/>
|
||||||
|
<field name="name"/>
|
||||||
|
</form>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?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="name"/>
|
||||||
|
</tree>
|
18
weighing.py
18
weighing.py
|
@ -262,22 +262,6 @@ class Weighing(Workflow, ModelSQL, ModelView):
|
||||||
def on_change_with_netweight(self):
|
def on_change_with_netweight(self):
|
||||||
return (self.weight or 0) - (self.tara or 0)
|
return (self.weight or 0) - (self.tara or 0)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def validate(cls, records):
|
|
||||||
super().validate(records)
|
|
||||||
cls.check_percent_beneficiaries(records)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def check_percent_beneficiaries(cls, records):
|
|
||||||
for record in records:
|
|
||||||
if record.state == 'draft':
|
|
||||||
continue
|
|
||||||
percent = sum([x.percent for x in record.beneficiaries])
|
|
||||||
if record.beneficiaries and abs(100 - round(percent, 2)) > 0.0001:
|
|
||||||
raise UserError(gettext('agronomics.msg_beneficiaris_percent',
|
|
||||||
crop=record.crop.rec_name,
|
|
||||||
plantation=record.plantations[0].plantation.rec_name))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@Workflow.transition('in_analysis')
|
@Workflow.transition('in_analysis')
|
||||||
def analysis(cls, weighings):
|
def analysis(cls, weighings):
|
||||||
|
@ -426,7 +410,7 @@ class Weighing(Workflow, ModelSQL, ModelView):
|
||||||
b = Beneficiary()
|
b = Beneficiary()
|
||||||
b.party = ben.party
|
b.party = ben.party
|
||||||
b.weighing = weighing
|
b.weighing = weighing
|
||||||
b.percent = ben.percent
|
b.product_price_list_type = ben.product_price_list_type
|
||||||
to_save.append(b)
|
to_save.append(b)
|
||||||
|
|
||||||
if to_save:
|
if to_save:
|
||||||
|
|
Loading…
Reference in New Issue