Skip to content

Commit

Permalink
[IMP+ADD] purchase_order_move_menu, purchase_order_move_menu_spil: ad…
Browse files Browse the repository at this point in the history
…d First invoice date stored and refactor them
  • Loading branch information
ChristianSantamaria committed Sep 6, 2023
1 parent fe021b5 commit 8c43d99
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 114 deletions.
2 changes: 1 addition & 1 deletion purchase_order_move_menu/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
""",
"author": "Solvos",
"license": "LGPL-3",
"version": "13.0.1.0.0",
"version": "13.0.2.0.0",
"category": "Operations/Purchase",
"website": "https://github.com/solvosci/slv-purchase",
"depends": ["purchase_stock"],
Expand Down
47 changes: 12 additions & 35 deletions purchase_order_move_menu/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-21 14:02+0000\n"
"PO-Revision-Date: 2022-04-21 14:02+0000\n"
"Last-Translator: \n"
"POT-Creation-Date: 2022-05-19 11:52+0000\n"
"PO-Revision-Date: 2022-05-19 13:54+0200\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__po_menu_price_amount_total
msgid "Amount Total"
msgstr "Importe Total"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.0\n"
"Last-Translator: \n"
"Language: es_ES\n"

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__po_currency_id
Expand All @@ -40,6 +37,11 @@ msgstr "Desde"
msgid "Group By"
msgstr "Agrupar por"

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_search
msgid "Location Orig"
msgstr "Ubicaci??n Origen"

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__purchase_order
msgid "Order Reference"
Expand All @@ -50,11 +52,6 @@ msgstr "Ref. pedido"
msgid "Picking"
msgstr "Albar??n"

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__po_menu_invoice_lines_count
msgid "Po Menu Invoice Lines Count"
msgstr "Men?? recuento de l??neas de factura - Compras"

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_search
msgid "Product"
Expand All @@ -81,11 +78,6 @@ msgstr "Pedido de compra"
msgid "Purchase Representative"
msgstr "Representante de compras"

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_tree
msgid "Quantity"
msgstr "Cantidad"

#. module: purchase_order_move_menu
#: model:ir.model.fields,help:purchase_order_move_menu.field_stock_move__po_product_categ_id
msgid "Select category for the current product"
Expand All @@ -106,21 +98,6 @@ msgstr "Movimientos de Inventario"
msgid "To"
msgstr "Hasta"

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_tree
msgid "Total Amount"
msgstr "Importe total"

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_tree
msgid "Total Quantity"
msgstr "Cantidad total"

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__po_menu_price_unit
msgid "Unit Price"
msgstr "Precio unitario"

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_tree
msgid "Unit of Measure"
Expand Down
39 changes: 7 additions & 32 deletions purchase_order_move_menu/i18n/purchase_order_move_menu.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-21 14:01+0000\n"
"PO-Revision-Date: 2022-04-21 14:01+0000\n"
"POT-Creation-Date: 2022-05-19 11:52+0000\n"
"PO-Revision-Date: 2022-05-19 11:52+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__po_menu_price_amount_total
msgid "Amount Total"
msgstr ""

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__po_currency_id
msgid "Currency"
Expand All @@ -40,6 +35,11 @@ msgstr ""
msgid "Group By"
msgstr ""

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_search
msgid "Location Orig"
msgstr ""

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__purchase_order
msgid "Order Reference"
Expand All @@ -50,11 +50,6 @@ msgstr ""
msgid "Picking"
msgstr ""

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__po_menu_invoice_lines_count
msgid "Po Menu Invoice Lines Count"
msgstr ""

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_search
msgid "Product"
Expand All @@ -81,11 +76,6 @@ msgstr ""
msgid "Purchase Representative"
msgstr ""

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_tree
msgid "Quantity"
msgstr ""

#. module: purchase_order_move_menu
#: model:ir.model.fields,help:purchase_order_move_menu.field_stock_move__po_product_categ_id
msgid "Select category for the current product"
Expand All @@ -106,21 +96,6 @@ msgstr ""
msgid "To"
msgstr ""

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_tree
msgid "Total Amount"
msgstr ""

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_tree
msgid "Total Quantity"
msgstr ""

#. module: purchase_order_move_menu
#: model:ir.model.fields,field_description:purchase_order_move_menu.field_stock_move__po_menu_price_unit
msgid "Unit Price"
msgstr ""

#. module: purchase_order_move_menu
#: model_terms:ir.ui.view,arch_db:purchase_order_move_menu.stock_move_po_move_menu_tree
msgid "Unit of Measure"
Expand Down
41 changes: 1 addition & 40 deletions purchase_order_move_menu/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# ?? 2022 Solvos Consultor??a Inform??tica (<http://www.solvos.es>)
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)

from odoo import api, fields, models
from odoo.tools import float_compare
from odoo import fields, models


class StockMove(models.Model):
Expand All @@ -21,41 +20,3 @@ class StockMove(models.Model):
purchase_user_id = fields.Many2one(
related="purchase_line_id.order_id.user_id",
)

po_menu_price_unit = fields.Float(
compute="_compute_po_menu_price_amount_total",
string="Unit Price",
store=True,
)
po_menu_price_amount_total = fields.Monetary(
compute="_compute_po_menu_price_amount_total",
string="Amount Total",
currency_field="po_currency_id",
store=True,
)
po_menu_invoice_lines_count = fields.Integer(
compute="_compute_po_menu_price_amount_total",
store=True,
)

@api.depends(
"purchase_line_id.price_unit",
"quantity_done",
"purchase_line_id.invoice_lines",
"purchase_line_id.invoice_lines.price_unit",
"purchase_line_id.invoice_lines.quantity"
)
def _compute_po_menu_price_amount_total(self):
precision = self.env["decimal.precision"].precision_get(
"Product Price"
)
for record in self:
record.po_menu_invoice_lines_count = len(record.purchase_line_id.invoice_lines)
prices = [invoice.price_unit for invoice in record.purchase_line_id.invoice_lines]

if any(1 if float_compare(prices[0], price, precision_digits=precision) else 0 for price in prices) or record.po_menu_invoice_lines_count == 0:
record.po_menu_price_unit = record.purchase_line_id.price_unit
record.po_menu_price_amount_total = record.po_menu_price_unit * record.quantity_done
else:
record.po_menu_price_unit = prices[0]
record.po_menu_price_amount_total = record.po_menu_price_unit * record.quantity_done
1 change: 1 addition & 0 deletions purchase_order_move_menu/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* David Alonso <[email protected]>
* Christian Santamar??a <[email protected]>
8 changes: 2 additions & 6 deletions purchase_order_move_menu/views/stock_move_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<filter string="Purchase Order" name="groupby_purchase_order" domain="[]" context="{'group_by': 'purchase_order'}"/>
<filter string="Vendor" name="groupby_purchase_partner_id" domain="[]" context="{'group_by': 'purchase_partner_id'}"/>
<filter string="Date" name="date" domain="[]" context="{'group_by': 'date'}"/>
<filter string="Location Orig" name="groupby_location_id" domain="[]" context="{'group_by': 'location_id'}"/>
</group>

</search>
Expand All @@ -36,8 +37,7 @@
<field name="name">stock.move.tree (Purchase Moves)</field>
<field name="model">stock.move</field>
<field name="arch" type="xml">
<tree default_order="date" decoration-success="po_menu_invoice_lines_count == 1" decoration-info="po_menu_invoice_lines_count == 0" decoration-muted="po_menu_invoice_lines_count > 1">
<field name="po_menu_invoice_lines_count" invisible="1"/>
<tree default_order="date">
<field name="date"/>
<field name="reference"/>
<field name="purchase_line_id" invisible="1"/>
Expand All @@ -48,11 +48,7 @@
<field name="location_id" options="{'no_create': True}" string="From" optional="hide"/>
<field name="location_dest_id" options="{'no_create': True}" string="To" optional="show"/>
<field name="purchase_partner_id" />
<field name="quantity_done" string="Quantity" sum="Total Quantity"/>
<field name="product_uom" options="{'no_open': True, 'no_create': True}" string="Unit of Measure" groups="uom.group_uom"/>
<field name="po_currency_id" invisible="1"/>
<field name="po_menu_price_unit"/>
<field name="po_menu_price_amount_total" widget="monetary" sum="Total Amount"/>
<field name="state" invisible="1"/>
</tree>
</field>
Expand Down

0 comments on commit 8c43d99

Please sign in to comment.