Skip to content
Closed
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
3 changes: 2 additions & 1 deletion purchase_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
"name": "Purchase UX",
"version": "18.0.1.1.0",
"version": "18.0.1.2.0",
"category": "Purchases",
"sequence": 14,
"summary": "",
Expand All @@ -41,6 +41,7 @@
"views/purchase_line_views.xml",
"views/product_template_views.xml",
"views/product_supplierinfo_views.xml",
"views/purchase_bill_line_match_views.xml",
],
"demo": [
"demo/purchase_order_demo.xml",
Expand Down
5 changes: 5 additions & 0 deletions purchase_ux/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,8 @@ msgstr "o"
#: model:ir.model,name:purchase_ux.model_purchase_order_line_add_to_invoice
msgid "purchase.order.line.add_to_invoice"
msgstr ""

#. module: purchase_ux
#: model:ir.model,name:purchase_ux.model_purchase_bill_line_match
msgid "Received"
msgstr "Recibido"
1 change: 1 addition & 0 deletions purchase_ux/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from . import purchase_order
from . import purchase_order_line
from . import product_template
from . import purchase_bill_line_match
12 changes: 12 additions & 0 deletions purchase_ux/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ def update_prices_with_supplier_cost(self):

def get_product_lines_to_update(self):
return self.with_company(self.company_id.id).invoice_line_ids.filtered(lambda x: x.product_id and x.price_unit)

def action_purchase_matching(self):
result = super().action_purchase_matching()
result["context"] = result.get("context", {})
result["context"].update(
{
"search_default_pol_id": 1,
"search_default_not_invoiced": 1,
"search_default_current_invoice": 1,
}
)
return result
39 changes: 39 additions & 0 deletions purchase_ux/models/purchase_bill_line_match.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import api, fields, models


class PurchaseBillLineMatch(models.Model):
_inherit = "purchase.bill.line.match"

reference_description = fields.Char(
string="Description",
compute="_compute_reference_description",
)

qty_received = fields.Float(
string="Received",
related="pol_id.qty_received",
readonly=True,
)

@api.depends("pol_id", "product_id", "display_name")
def _compute_reference_description(self):
for rec in self:
if rec.pol_id and rec.product_id:
pol_name = rec.pol_id.name or ""
product_name = rec.product_id.display_name or ""
if pol_name.startswith(product_name):
remaining = pol_name[len(product_name) :].strip()
if remaining:
rec.reference_description = f"{product_name} - {remaining}"
else:
rec.reference_description = product_name
else:
rec.reference_description = pol_name
elif rec.pol_id:
rec.reference_description = rec.pol_id.name
else:
rec.reference_description = rec.display_name
12 changes: 12 additions & 0 deletions purchase_ux/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,15 @@ def _prepare_invoice(self):
if self.internal_notes:
result["internal_notes"] = self.internal_notes
return result

def action_bill_matching(self):
result = super().action_bill_matching()
result["context"] = result.get("context", {})
result["context"].update(
{
"search_default_pol_id": 1,
"search_default_not_invoiced": 1,
"search_default_current_invoice": 1,
}
)
return result
29 changes: 29 additions & 0 deletions purchase_ux/views/purchase_bill_line_match_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="purchase_bill_line_match_tree_ux" model="ir.ui.view">
<field name="name">purchase.bill.line.match.list</field>
<field name="model">purchase.bill.line.match</field>
<field name="inherit_id" ref="purchase.purchase_bill_line_match_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='display_name']" position="replace">
<field name="reference_description" string="Description" decoration-it="not product_id"/>
</xpath>
<xpath expr="//field[@name='product_uom_qty']" position="after">
<field name="qty_received" string="Qty Received" optional="show"/>
</xpath>
</field>
</record>

<record id="purchase_bill_line_match_search" model="ir.ui.view">
<field name="name">purchase.bill.line.match.search</field>
<field name="model">purchase.bill.line.match</field>
<field name="arch" type="xml">
<search>
<filter string="Órdenes de Compra" name="pol_id" domain="[('pol_id', '!=', False)]"/>
<separator/>
<filter string="No Facturado" name="not_invoiced" domain="[('account_move_id', '=', False)]"/>
<filter string="En Factura Actual" name="current_invoice" domain="[('account_move_id', '!=', False), ('state', '=', 'draft')]"/>
</search>
</field>
</record>
</odoo>