Add the incoming productions moves as a outgoing moves to control all moves on a sema view

Add quantity and state field for outmove movemnt from the shipment
This commit is contained in:
Bernat Brunet 2020-07-02 11:16:21 +02:00
parent 5eb4424c57
commit c3e90b10c2
8 changed files with 84 additions and 9 deletions

View File

@ -123,3 +123,11 @@ msgstr "Moviments de sortida"
msgctxt "model:ir.ui.menu,name:menu_move_out_form"
msgid "Moves Out"
msgstr "Moviments de sortida"
msgctxt "view:stock.move:"
msgid "Move Out Quantity"
msgstr "Quantitat moviment sortida"
msgctxt "view:stock.move:"
msgid "Move Out State"
msgstr "Estat moviment sortida"

View File

@ -123,3 +123,11 @@ msgstr "Movimentos de salida"
msgctxt "model:ir.ui.menu,name:menu_move_out_form"
msgid "Moves Out"
msgstr "Movimentos de salida"
msgctxt "view:stock.move:"
msgid "Move Out Quantity"
msgstr "Cantidad movimiento salida"
msgctxt "view:stock.move:"
msgid "Move Out State"
msgstr "Estado movimiento salida"

59
move.py
View File

@ -2,6 +2,9 @@
# copyright notices and license terms.
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
from sql import Column, Cast
from sql.operators import Concat
__all__ = ['Move']
@ -14,8 +17,19 @@ class Move(metaclass=PoolMeta):
warehouse_customer = fields.Function(fields.Many2One('stock.location',
'Warehouse', domain=[('type', '=', 'warehouse')]),
'get_sale_relation', searcher='search_warehouse_customer')
shipment_customer = fields.Function(fields.Many2One('party.party', 'Customer'),
'get_sale_relation', searcher='search_shipment_customer')
shipment_customer = fields.Function(fields.Many2One('party.party',
'Customer'), 'get_sale_relation', searcher='search_shipment_customer')
origin_state = fields.Function(fields.Selection([
('staging', 'Staging'),
('draft', 'Draft'),
('assigned', 'Assigned'),
('done', 'Done'),
('cancel', 'Canceled'),
], 'Move Inventori State'), 'get_origin_move_field',
searcher='search_origin_move_field')
origin_quantity = fields.Function(fields.Float("Move Inventory Quantity",
digits=(16, Eval('unit_digits', 2))), 'get_origin_move_field',
searcher='search_origin_move_field')
@classmethod
def get_sale_relation(cls, moves, names):
@ -80,3 +94,44 @@ class Move(metaclass=PoolMeta):
+ tuple(clause[3:]),
('sale.party',) + tuple(clause[1:]),
]
@classmethod
def get_origin_move_field(cls, moves, names):
result = {
'origin_state': {},
'origin_quantity': {},
}
for move in moves:
origins = cls.search([
('origin', '=', 'stock.move,' + str(move.id)),
])
origin = origins[0] if origins else None
result['origin_state'][move.id] = (origin.state
if origin else None)
result['origin_quantity'][move.id] = (origin.quantity
if origin else None)
return result
@classmethod
def search_origin_move_field(cls, name, clause):
pool = Pool()
Move = pool.get('stock.move')
sql_table = cls.__table__()
move = Move.__table__()
column, operator, value = clause
res = {
'origin_state': 'state',
'origin_quantity': 'quantity',
}
column = Column(move, res[column])
Operator = fields.SQL_OPERATORS[operator]
_, move_type = Move.origin.sql_type()
query = sql_table.join(move,
condition=move.origin == Concat('stock.move,',
Cast(sql_table.id, move_type))).select(
sql_table.id,
where=move.origin.like('stock.move,%') &
Operator(column, value),
)
return [('id', 'in', query)]

View File

@ -7,7 +7,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.act_window" id="act_party_move_out_form2">
<field name="name">Moves Out</field>
<field name="res_model">stock.move</field>
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('shipment_customer', '=', Eval('active_id')), ('shipment_customer', 'in', Eval('active_ids'))), ['OR', ('to_location.type', '=', 'customer'), ('from_location.type', '=', 'customer')]]" pyson="1"/>
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('shipment_customer', '=', Eval('active_id')), ('shipment_customer', 'in', Eval('active_ids'))), ['OR', ('to_location.type', 'in', ['customer', 'production']), ('from_location.type', '=', 'customer')]]" pyson="1"/>
</record>
<record model="ir.action.act_window.domain" id="act_party_move_out_form_domain_pending_overdue">
<field name="name">Overdue pending incoming</field>

View File

@ -7,7 +7,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.act_window" id="act_product_move_in_form2">
<field name="name">Moves Out</field>
<field name="res_model">stock.move</field>
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('product', '=', Eval('active_id')), ('product', 'in', Eval('active_ids'))), ['OR', ('to_location.type', '=', 'customer'), ('from_location.type', '=', 'customer')]]" pyson="1"/>
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('product', '=', Eval('active_id')), ('product', 'in', Eval('active_ids'))), ['OR', ('to_location.type', 'in', ['customer', 'production']), ('from_location.type', '=', 'customer')]]" pyson="1"/>
</record>
<record model="ir.action.act_window.domain" id="act_product_move_in_form_domain_pending_overdue">
<field name="name">Overdue pending incoming</field>
@ -53,7 +53,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.act_window" id="act_product_template_move_in_form2">
<field name="name">Moves Out</field>
<field name="res_model">stock.move</field>
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('product.template', '=', Eval('active_id')), ('product.template', 'in', Eval('active_ids'))), ['OR', ('to_location.type', '=', 'customer'), ('from_location.type', '=', 'customer')]]" pyson="1"/>
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('product.template', '=', Eval('active_id')), ('product.template', 'in', Eval('active_ids'))), ['OR', ('to_location.type', 'in', ['customer', 'production']), ('from_location.type', '=', 'customer')]]" pyson="1"/>
</record>
<record model="ir.action.act_window.domain" id="act_product_template_move_in_form_domain_pending_overdue">
<field name="name">Overdue pending incoming</field>

View File

@ -7,7 +7,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.act_window" id="act_sale_move_out_form2">
<field name="name">Moves Out</field>
<field name="res_model">stock.move</field>
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('sale', '=', Eval('active_id')), ('sale', 'in', Eval('active_ids'))), ['OR', ('to_location.type', '=', 'customer'), ('from_location.type', '=', 'customer')]]" pyson="1"/>
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('sale', '=', Eval('active_id')), ('sale', 'in', Eval('active_ids'))), ['OR', ('to_location.type', 'in', ['customer', 'production']), ('from_location.type', '=', 'customer')]]" pyson="1"/>
</record>
<record model="ir.action.act_window.domain" id="act_sale_move_out_form_domain_pending_overdue">
<field name="name">Overdue pending incoming</field>

View File

@ -13,7 +13,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.act_window" id="act_move_out_form">
<field name="name">Moves Out</field>
<field name="res_model">stock.move</field>
<field name="domain" eval="['OR', ('to_location.type', '=', 'customer'), ('from_location.type', '=', 'customer')]" pyson="1"/>
<field name="domain" eval="['OR', ('to_location.type', 'in', ['customer', 'production']), ('from_location.type', '=', 'customer')]" pyson="1"/>
<field name="search_value"
eval="[('create_date', '>=', DateTime(hour=0, minute=0, second=0, microsecond=0, delta_years=-1))]"
pyson="1"/>

View File

@ -5,12 +5,16 @@ this repository contains the full copyright notices and license terms. -->
<field name="shipment_customer"/>
<field name="sale"/>
<field name="shipment" expand="1"/>
<field name="production_input"/>
<field name="product"/>
<field name="quantity"/>
<field name="quantity" string="Move Out Quantity"/>
<field name="origin_quantity"/>
<field name="uom"/>
<field name="planned_date"/>
<field name="effective_date"/>
<field name="warehouse_customer"/>
<field name="unit_price"/>
<field name="state"/>
<field name="cost_price"/>
<field name="state" string="Move Out State"/>
<field name="origin_state"/>
</tree>