Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions stock_request_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
"name": "Stock Request UX",
"version": "18.0.1.0.0",
"version": "19.0.1.0.0",
"category": "Warehouse Management",
"sequence": 14,
"summary": "",
Expand All @@ -32,15 +32,13 @@
"stock_ux",
],
"data": [
"views/product_product_views.xml",
"views/product_template_views.xml",
"views/stock_request_order_views.xml",
"views/stock_request_views.xml",
"views/stock_move_views.xml",
"views/stock_picking_views.xml",
],
"demo": [],
"installable": False,
"installable": True,
"auto_install": True,
"application": False,
"post_init_hook": "init_settings",
Expand Down
22 changes: 1 addition & 21 deletions stock_request_ux/models/stock_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
class StockRequest(models.Model):
_inherit = "stock.request"

picking_ids = fields.One2many(
compute="_compute_picking_ids",
)
picking_count = fields.Integer(
compute="_compute_picking_ids",
)
# clean this field because of _check_product_stock_request
# and the fact that we add copy=True to stock_request_ids
procurement_group_id = fields.Many2one(
copy=False,
)
order_id = fields.Many2one(
ondelete="cascade",
)
Expand All @@ -30,15 +19,6 @@ def onchange_product_id(self):
self.route_id = self.order_id.route_id.id
return res

@api.depends("allocation_ids")
def _compute_picking_ids(self):
sro_with_procurement = self.filtered("procurement_group_id")
(self - sro_with_procurement).update({"picking_ids": self.env["stock.picking"], "picking_count": 0})
for rec in sro_with_procurement:
all_moves = self.env["stock.move"].search([("group_id", "=", rec.procurement_group_id.id)])
rec.picking_ids = all_moves.mapped("picking_id")
rec.picking_count = len(rec.picking_ids)

# DEPRECATED def action_cancel(self):

def button_cancel_remaining(self):
Expand All @@ -55,7 +35,7 @@ def button_cancel_remaining(self):
# cosas que ya se entregaron parcialmente)
to_cancel_moves._action_cancel()
rec.order_id.message_post(
body=self.env._('Cancel remaining call for line "%s" (id %s), line ' "qty updated from %s to %s")
body=self.env._('Cancel remaining call for line "%s" (id %s), line qty updated from %s to %s')
% (rec.name, rec.id, old_product_uom_qty, rec.qty_done)
)
rec.check_done()
Expand Down
40 changes: 1 addition & 39 deletions stock_request_ux/models/stock_request_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,12 @@ class StockRequestOrder(models.Model):
_inherit = "stock.request.order"
_order = "id desc"

# este pickings es analogo al pickings de venta pero implementado mas facil
# odoo en ventas agrega un campo en el procurement group y related en
# picking pero a la larga esta trayendo todos los pickings que tengan
# el procurment group de la venta. Nosotros hacemos similar buscando los
# pickings que tengan mismo procurement group que el request order
# como al final tmb se puede cancelar una linea (stock request), lo
# implementamos en las lineas directamente el cancelar
picking_ids = fields.One2many(
compute="_compute_picking_ids",
)
picking_count = fields.Integer(
compute="_compute_picking_ids",
)
procurement_group_id = fields.Many2one(
copy=False,
)
warehouse_id = fields.Many2one(
change_default=True,
)

@api.depends("procurement_group_id")
def _compute_picking_ids(self):
sro_with_procurement = self.filtered("procurement_group_id")
(self - sro_with_procurement).update({"picking_ids": self.env["stock.picking"], "picking_count": 0})
for rec in sro_with_procurement:
all_moves = self.env["stock.move"].search([("group_id", "=", rec.procurement_group_id.id)])
rec.picking_ids = all_moves.mapped("picking_id")
rec.picking_count = len(rec.picking_ids)

@api.model_create_multi
def create(self, vals_list):
recs = super().create(vals_list)
for rec in recs:
if not rec.procurement_group_id:
# setamos al group el partner del warehouse
# para que se propague a los pickings
group = self.env["procurement.group"].create({})
rec.procurement_group_id = group.id
for stock_rq in rec.stock_request_ids:
stock_rq.write({"procurement_group_id": rec.procurement_group_id.id})
return recs

@api.onchange("route_id")
def onchange_procurement_group_id(self):
def onchange_route_id(self):
for line in self.stock_request_ids:
if self.route_id.id in line.route_ids.ids:
line.route_id = self.route_id.id
25 changes: 1 addition & 24 deletions stock_request_ux/views/product_product_views.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_form_view_procurement_button" model="ir.ui.view">
<field name="name">product.product.procurement</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.product_form_view_procurement_button"/>
<field name="arch" type="xml">
<button name="%(stock.action_product_replenish)d" position="attributes">
<attribute name="invisible">True</attribute>
<attribute name="groups"></attribute>
</button>
</field>
</record>
<record id="product_product_view_form_easy_inherit_stock" model="ir.ui.view">
<field name="name">product.product.view.form.easy.inherit.stock</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.product_product_view_form_easy_inherit_stock"/>
<field name="arch" type="xml">
<button name="%(stock.action_product_replenish)d" position="attributes">
<attribute name="invisible">True</attribute>
<attribute name="groups"></attribute>
</button>
</field>
</record>
</odoo>
<odoo/>
14 changes: 1 addition & 13 deletions stock_request_ux/views/product_template_views.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_template_form_view_procurement_button" model="ir.ui.view">
<field name="name">product.template.procurement</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.product_template_form_view_procurement_button"/>
<field name="arch" type="xml">
<button name="%(stock.action_product_replenish)d" position="attributes">
<attribute name="invisible">True</attribute>
<attribute name="groups"></attribute>
</button>
</field>
</record>
</odoo>
<odoo/>
Loading