parent
456930c1c2
commit
15154fe2de
|
@ -32,6 +32,8 @@ def register():
|
|||
product.ProductCrop,
|
||||
product.ProductDO,
|
||||
product.ProductEcological,
|
||||
product.ProductPriceListType,
|
||||
product.PriceList,
|
||||
product.ProductVariety,
|
||||
product.Template,
|
||||
weighing.WeighingCenter,
|
||||
|
|
48
plot.py
48
plot.py
|
@ -4,6 +4,7 @@ from trytond.model import fields, ModelSQL, ModelView
|
|||
from trytond.pool import Pool
|
||||
from trytond.i18n import gettext
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
class Enclosure(ModelSQL, ModelView):
|
||||
"Enclosure"
|
||||
|
@ -62,11 +63,13 @@ class Plantation(ModelSQL, ModelView):
|
|||
"Plantation"
|
||||
__name__ = 'agronomics.plantation'
|
||||
|
||||
code = fields.Char('Code', required=True)
|
||||
party = fields.Many2One('party.party', 'Party', required=True)
|
||||
code = fields.Char("Code", required=True)
|
||||
party = fields.Many2One('party.party', "Party", required=True)
|
||||
enclosures = fields.One2Many('agronomics.enclosure', 'plantation',
|
||||
'Enclosure')
|
||||
parcels = fields.One2Many('agronomics.parcel', 'plantation', 'Parcel')
|
||||
"Enclosure")
|
||||
parcels = fields.One2Many('agronomics.parcel', 'plantation', "Parcel")
|
||||
platation_year = fields.Integer("Platation Year")
|
||||
platation_owner = fields.Many2One('party.party', "Platation Owner")
|
||||
|
||||
def get_rec_name(self, name):
|
||||
if self.code:
|
||||
|
@ -121,20 +124,6 @@ class Parcel(ModelSQL, ModelView):
|
|||
if self.plantation and self.crop:
|
||||
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):
|
||||
return ",".join([x.name for x in self.denomination_origin])
|
||||
|
||||
|
@ -168,7 +157,22 @@ class Beneficiaries(ModelSQL, ModelView):
|
|||
"Beneficiaries"
|
||||
__name__ = 'agronomics.beneficiary'
|
||||
|
||||
party = fields.Many2One('party.party', 'Beneficiary', required=True)
|
||||
percent = fields.Float('Percent', digits=(16, 2), required=True)
|
||||
parcel = fields.Many2One('agronomics.parcel', 'Parcel')
|
||||
weighing = fields.Many2One('agronomics.weighing', 'Weighing')
|
||||
party = fields.Many2One('party.party', "Beneficiary", required=True)
|
||||
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)
|
||||
ecological = fields.Many2One('agronomics.ecological', 'Ecological',
|
||||
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_delete" eval="True"/>
|
||||
</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>
|
||||
</tryton>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<form>
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="percent"/>
|
||||
<field name="percent"/>
|
||||
<label name="product_price_list_type"/>
|
||||
<field name="product_price_list_type"/>
|
||||
<label name="parcel"/>
|
||||
<field name="parcel"/>
|
||||
</form>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<tree editable="1">
|
||||
<field name="party"/>
|
||||
<field name="percent"/>
|
||||
<field name="product_price_list_type"/>
|
||||
</tree>
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
<field name="code"/>
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="platation_year"/>
|
||||
<field name="platation_year"/>
|
||||
<label name="platation_owner"/>
|
||||
<field name="platation_owner"/>
|
||||
<notebook>
|
||||
<page name="parcels">
|
||||
<field name="parcels" widget="many2many"/>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<tree>
|
||||
<field name="code"/>
|
||||
<field name="party"/>
|
||||
<field name="platation_year" tree_invisible="1"/>
|
||||
<field name="platation_owner" tree_invisible="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="//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>
|
16
weighing.py
16
weighing.py
|
@ -262,22 +262,6 @@ class Weighing(Workflow, ModelSQL, ModelView):
|
|||
def on_change_with_netweight(self):
|
||||
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
|
||||
@Workflow.transition('in_analysis')
|
||||
def analysis(cls, weighings):
|
||||
|
|
Loading…
Reference in New Issue