Make supply production configurable
This commit is contained in:
parent
232ffb13b0
commit
2efaf0e151
|
@ -4,6 +4,7 @@
|
|||
from trytond.pool import Pool
|
||||
from .production import *
|
||||
from .sale import *
|
||||
from .configuration import *
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -13,6 +14,7 @@ def register():
|
|||
SaleLine,
|
||||
Sale,
|
||||
ChangeLineQuantityStart,
|
||||
Configuration,
|
||||
module='sale_supply_production', type_='model')
|
||||
Pool.register(
|
||||
ChangeQuantity,
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
__all__ = ['Configuration']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class Configuration:
|
||||
'Sale Configuration'
|
||||
__name__ = 'sale.configuration'
|
||||
sale_supply_production_default = fields.Boolean(
|
||||
'Sale Line Supply Production',
|
||||
help='Default Supply Production value for Sale Lines')
|
||||
|
||||
@staticmethod
|
||||
def default_sale_supply_production_default():
|
||||
return True
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view"
|
||||
id="sale_supply_production_configuration_view_form">
|
||||
<field name="model">sale.configuration</field>
|
||||
<field name="inherit" ref="sale.sale_configuration_view_form"/>
|
||||
<field name="name">configuration_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
9
sale.py
9
sale.py
|
@ -51,7 +51,8 @@ class Sale:
|
|||
def create_productions(self):
|
||||
productions = []
|
||||
for line in self.lines:
|
||||
productions += line.create_productions()
|
||||
if line.supply_production:
|
||||
productions += line.create_productions()
|
||||
return productions
|
||||
|
||||
def get_productions(self, name):
|
||||
|
@ -64,8 +65,14 @@ class Sale:
|
|||
class SaleLine:
|
||||
__name__ = 'sale.line'
|
||||
|
||||
supply_production = fields.Boolean('Supply Production')
|
||||
productions = fields.One2Many('production', 'origin', 'Productions')
|
||||
|
||||
@staticmethod
|
||||
def default_supply_production():
|
||||
SaleConfiguration = Pool().get('sale.configuration')
|
||||
return SaleConfiguration(1).sale_supply_production_default
|
||||
|
||||
def create_productions(self):
|
||||
pool = Pool()
|
||||
try:
|
||||
|
|
13
sale.xml
13
sale.xml
|
@ -7,7 +7,18 @@
|
|||
<field name="inherit" ref="sale.sale_view_form"/>
|
||||
<field name="name">sale_form</field>
|
||||
</record>
|
||||
|
||||
<!-- sale.line -->
|
||||
<record model="ir.ui.view" id="sale_line_view_form">
|
||||
<field name="model">sale.line</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="inherit" ref="sale.sale_line_view_form"/>
|
||||
<field name="name">sale_line_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="sale_line_view_tree_sequence">
|
||||
<field name="model">sale.line</field>
|
||||
<field name="inherit" ref="sale.sale_line_view_tree_sequence"/>
|
||||
<field name="name">sale_line_tree_sequence</field>
|
||||
</record>
|
||||
<!-- relates -->
|
||||
<record model="ir.action.act_window" id="act_production_form">
|
||||
<field name="name">Productions</field>
|
||||
|
|
|
@ -216,6 +216,11 @@ Sale product::
|
|||
>>> sale.lines.append(sale_line)
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 2.0
|
||||
>>> sale_line = SaleLine()
|
||||
>>> sale.lines.append(sale_line)
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 1.0
|
||||
>>> sale_line.supply_production = False
|
||||
>>> sale.save()
|
||||
>>> Sale.quote([sale.id], config.context)
|
||||
>>> Sale.confirm([sale.id], config.context)
|
||||
|
|
|
@ -15,3 +15,4 @@ extras_depend:
|
|||
xml:
|
||||
sale.xml
|
||||
production.xml
|
||||
configuration.xml
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<data>
|
||||
<xpath expr="/form" position="inside">
|
||||
<label name="sale_supply_production_default"/>
|
||||
<field name="sale_supply_production_default"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<data>
|
||||
<xpath expr="/form/notebook/page" position="inside">
|
||||
<label name="supply_production"/>
|
||||
<field name="supply_production"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<data>
|
||||
<xpath expr="/tree" position="inside">
|
||||
<field name="supply_production"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue