mirror of
https://gitlab.com/datalifeit/trytond-stock_distribute
synced 2023-12-14 05:02:53 +01:00
Refactorizar módulo
This commit is contained in:
parent
c3e56c5c5c
commit
7b5bf9143f
|
@ -1,15 +1,9 @@
|
|||
from trytond.pool import Pool
|
||||
from .stock import *
|
||||
from .production import *
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Move,
|
||||
Location,
|
||||
ProductionShipmentData,
|
||||
ProductionShipmentConfirm,
|
||||
module='production_shipment_distribute', type_='model'),
|
||||
Pool.register(
|
||||
ProductionShipment,
|
||||
module='production_shipment_distribute', type_='wizard')
|
||||
module='stock_distribute', type_='model')
|
|
@ -1,55 +0,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.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
|
||||
__all__ = ['ProductionShipment', 'ProductionShipmentData',
|
||||
'ProductionShipmentConfirm']
|
||||
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class ProductionShipment:
|
||||
__name__ = 'production.shipment'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(ProductionShipment, cls).__setup__()
|
||||
|
||||
def default_confirm(self, fields):
|
||||
pool = Pool()
|
||||
Confirm = pool.get('production.shipment.confirm')
|
||||
Move = pool.get('stock.move')
|
||||
|
||||
# res = super(ProductionShipment, self).default_confirm(fields)
|
||||
moves = []
|
||||
for m in self.location.stock:
|
||||
moves.append(Confirm.explode_move(m,
|
||||
self.date.planned_date,
|
||||
self.location.to_location))
|
||||
|
||||
# create new movements
|
||||
new_moves = Move.distribute(moves, self.location.sequence_order)
|
||||
|
||||
# TODO: verify KIT for distribute not occupy_space products
|
||||
result = []
|
||||
for m in new_moves:
|
||||
result.append(Confirm.explode_move_values(m))
|
||||
return {'moves': result}
|
||||
|
||||
|
||||
class ProductionShipmentData:
|
||||
__name__ = 'production.shipment.data'
|
||||
|
||||
sequence_order = fields.Selection([('ascendant', 'Ascendant'),
|
||||
('descendant', 'Descendant')],
|
||||
'Location Sequence order',
|
||||
required=True)
|
||||
|
||||
@staticmethod
|
||||
def default_sequence_order():
|
||||
return 'ascendant'
|
||||
|
||||
|
||||
class ProductionShipmentConfirm:
|
||||
__name__ = 'production.shipment.confirm'
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="shipment_data_view_form">
|
||||
<field name="model">production.shipment.data</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit" ref="production_shipment_internal.shipment_data_view_form" />
|
||||
<field name="name">shipment_data_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -3,8 +3,6 @@ version=3.2.1
|
|||
depends:
|
||||
stock_location_sequence
|
||||
stock_storage_space
|
||||
production_shipment_internal
|
||||
|
||||
xml:
|
||||
stock.xml
|
||||
production.xml
|
||||
stock.xml
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name='to_location']" position="after">
|
||||
<label name="sequence_order" />
|
||||
<field name="sequence_order" />
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in a new issue