Skip to content

Commit

Permalink
[FIX] product_template_year_consumption: move fields to correct module
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane committed Jan 28, 2025
1 parent 23a171d commit ba0cbf4
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 46 deletions.
3 changes: 2 additions & 1 deletion product_supplierinfo_usability/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
"website": "https://github.com/avanzosc/odoo-addons",
"depends": [
"purchase",
"purchase_stock",
"product_usability",
"product_template_year_consumption",
],
"data": [
"views/product_supplierinfo_views.xml",
"views/stock_warehouse_orderpoint_views.xml",
],
"installable": True,
}
18 changes: 0 additions & 18 deletions product_supplierinfo_usability/models/product_supplierinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ class ProductSupplierInfo(models.Model):
digits="Product Unit of Measure",
compute="_compute_supplierinfo_quantities",
)
consumed_last_twelve_months = fields.Float(
string="Consumed last twelve months",
digits="Product Unit of Measure",
compute="_compute_supplierinfo_quantities",
)
months_with_stock = fields.Integer(
string="Months with stock", compute="_compute_supplierinfo_quantities"
)
supplier_pending_to_receive = fields.Float(
string="Pending receipt from supplier",
compute="_compute_supplier_pending_to_receive",
Expand All @@ -51,16 +43,6 @@ def _compute_supplierinfo_quantities(self):
if supplierinfo.product_id
else supplierinfo.product_tmpl_id.outgoing_qty
)
supplierinfo.consumed_last_twelve_months = (
supplierinfo.product_id.consumed_last_twelve_months
if supplierinfo.product_id
else supplierinfo.product_tmpl_id.consumed_last_twelve_months
)
supplierinfo.months_with_stock = (
supplierinfo.product_id.months_with_stock
if supplierinfo.product_id
else supplierinfo.product_tmpl_id.months_with_stock
)

def _compute_supplier_pending_to_receive(self):
stock_move_obj = self.env["stock.move"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class StockWarehouseOrderpoint(models.Model):
_inherit = "stock.warehouse.orderpoint"

supplier_pending_to_receive = fields.Float(
string="Pending receipt from supplier",
related="supplier_id.supplier_pending_to_receive",
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<field name="incoming_qty" optional="show" />
<field name="outgoing_qty" optional="show" />
<field name="supplier_pending_to_receive" optional="show" />
<field name="consumed_last_twelve_months" optional="show" />
<field name="months_with_stock" optional="show" />
</field>
</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_warehouse_orderpoint_tree_editable" model="ir.ui.view">
<field name="model">stock.warehouse.orderpoint</field>
<field name="inherit_id" ref="stock.view_warehouse_orderpoint_tree_editable" />
<field name="arch" type="xml">
<field name="route_id" position="after">
<field name="supplier_id" optional="show" />
<field name="supplier_pending_to_receive" optional="hide" />
</field>
</field>
</record>

<record id="view_warehouse_orderpoint_tree_editable_config" model="ir.ui.view">
<field name="model">stock.warehouse.orderpoint</field>
<field
name="inherit_id"
ref="stock.view_warehouse_orderpoint_tree_editable_config"
/>
<field name="arch" type="xml">
<field name="route_id" position="after">
<field name="supplier_id" optional="show" />
<field name="supplier_pending_to_receive" optional="hide" />
</field>
</field>
</record>
</odoo>
2 changes: 2 additions & 0 deletions product_template_year_consumption/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
"depends": [
"stock",
"sale",
"product",
],
"data": [
"views/product_product_views.xml",
"views/product_template_views.xml",
"views/product_supplierinfo_views.xml",
"views/stock_warehouse_orderpoint_views.xml",
],
"license": "AGPL-3",
Expand Down
1 change: 1 addition & 0 deletions product_template_year_consumption/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import product_product
from . import product_template
from . import product_supplierinfo
from . import stock_warehouse_orderpoint
30 changes: 30 additions & 0 deletions product_template_year_consumption/models/product_supplierinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


class ProductSupplierInfo(models.Model):
_inherit = "product.supplierinfo"

consumed_last_twelve_months = fields.Float(
string="Consumed last twelve months",
digits="Product Unit of Measure",
compute="_compute_months_qtys_quantities",
)
months_with_stock = fields.Integer(
string="Months with stock",
compute="_compute_months_qtys_quantities",
)

def _compute_months_qtys_quantities(self):
for supplierinfo in self:
supplierinfo.consumed_last_twelve_months = (
supplierinfo.product_id.consumed_last_twelve_months
if supplierinfo.product_id
else supplierinfo.product_tmpl_id.consumed_last_twelve_months
)
supplierinfo.months_with_stock = (
supplierinfo.product_id.months_with_stock
if supplierinfo.product_id
else supplierinfo.product_tmpl_id.months_with_stock
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="product_supplierinfo_tree_view" model="ir.ui.view">
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_tree_view" />
<field name="arch" type="xml">
<field name="delay" position="after">
<field name="consumed_last_twelve_months" optional="show" />
<field name="months_with_stock" optional="show" />
</field>
</field>
</record>
</odoo>
1 change: 0 additions & 1 deletion stock_usability/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"stock",
"purchase_stock",
"product_usability",
"product_supplierinfo_usability",
],
"data": [
"views/stock_warehouse_orderpoint_views.xml",
Expand Down
4 changes: 0 additions & 4 deletions stock_usability/models/stock_warehouse_orderpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ class StockWarehouseOrderpoint(models.Model):
digits="Product Unit of Measure",
compute="_compute_quantities",
)
supplier_pending_to_receive = fields.Float(
string="Pending receipt from supplier",
related="supplier_id.supplier_pending_to_receive",
)

def _compute_quantities(self):
for record in self:
Expand Down
20 changes: 0 additions & 20 deletions stock_usability/views/stock_warehouse_orderpoint_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@
</field>
</record>

<record
id="view_warehouse_orderpoint_tree_editable_inherited_mr"
model="ir.ui.view"
>
<field name="model">stock.warehouse.orderpoint</field>
<field
name="inherit_id"
ref="purchase_stock.view_warehouse_orderpoint_tree_editable_inherited_mrp"
/>
<field name="arch" type="xml">
<field name="supplier_id" position="after">
<field name="supplier_pending_to_receive" optional="show" />
</field>
</field>
</record>

<record id="view_warehouse_orderpoint_tree_editable_config" model="ir.ui.view">
<field name="model">stock.warehouse.orderpoint</field>
<field
Expand All @@ -38,10 +22,6 @@
<field name="incoming_qty" optional="show" />
<field name="outgoing_qty" optional="show" />
</field>
<field name="route_id" position="after">
<field name="supplier_id" optional="show" />
<field name="supplier_pending_to_receive" optional="show" />
</field>
<field name="qty_multiple" position="after">
<field name="qty_to_order" optional="show" />
</field>
Expand Down

0 comments on commit ba0cbf4

Please sign in to comment.