Add produced to sale line

This commit is contained in:
Oscar 2022-02-17 11:43:51 -05:00
parent 471a426f94
commit 6fe38331e7
6 changed files with 56 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import ir
import bom
import configuration
import product
import sale
def register():
@ -22,6 +23,7 @@ def register():
ir.Cron,
bom.BOM,
bom.BOMDirectCost,
sale.SaleLine,
module='production_accounting', type_='model')
Pool.register(
production.ProductionDetailed,

View File

@ -516,6 +516,7 @@ class ProcessProductionAsync(Wizard):
('sale.sale_date', '=', self.start.date),
('product.template.producible', '=', True),
('type', '=', 'line'),
('produced', '=', False),
]
lines = SaleLine.search(dom)
@ -540,7 +541,6 @@ class ProcessProductionAsync(Wizard):
'quantity': [line.quantity],
'bom': output.bom,
}
print(producibles)
self.create_production_moves(producibles, journal, period_id)
self.create_stock_moves(producibles)
return 'end'

28
sale.py Normal file
View File

@ -0,0 +1,28 @@
# 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 datetime import timedelta, date
from itertools import chain
from sql import Table
from decimal import Decimal
from trytond.model import fields, ModelSQL, ModelView
from trytond.pool import PoolMeta
# from trytond.pyson import Eval
# from trytond.transaction import Transaction
# from trytond.exceptions import UserError
# from trytond.report import Report
# from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport
class SaleLine(metaclass=PoolMeta):
__name__ = 'sale.line'
produced = fields.Boolean('Produced', states={'readonly': True})
@classmethod
def copy(cls, lines, default=None):
if default is None:
default = {}
else:
default = default.copy()
default.setdefault('produced', None)
return super(SaleLine, cls).copy(lines, default)

14
sale.xml Normal file
View File

@ -0,0 +1,14 @@
<?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="sale_line_view_form">
<field name="model">sale.line</field>
<field name="inherit" ref="sale.sale_line_view_form"/>
<field name="name">sale_line_form</field>
</record>
</data>
</tryton>

View File

@ -14,3 +14,4 @@ xml:
production.xml
product.xml
bom.xml
sale.xml

10
view/sale_line_form.xml Normal file
View File

@ -0,0 +1,10 @@
<?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/notebook/page[@id='general']/field[@name='description']"
position="after">
<label name="produced"/>
<field name="produced"/>
</xpath>
</data>