Skip to content
Merged
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
9 changes: 2 additions & 7 deletions purchase_order_type_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@

{
"name": "Purchase Order Type UX",
"version": "18.0.1.0.0",
"version": "18.0.1.1.0",
"category": "Purchases",
"sequence": 14,
"summary": "",
"author": "ADHOC SA",
"website": "www.adhoc.com.ar",
"license": "AGPL-3",
"images": [],
"depends": [
"project",
"purchase_stock_ux",
"l10n_ar_purchase",
"purchase_order_type",
],
"depends": ["project", "purchase_stock_ux", "l10n_ar_purchase", "purchase_order_type", "account_multicompany_ux"],
"data": [
"views/purchase_order_type_views.xml",
"views/account_move_views.xml",
Expand Down
10 changes: 8 additions & 2 deletions purchase_order_type_ux/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#
# Translators:
# Juan José Scarafía <scarafia.juanjose@gmail.com>, 2025
# migration.bot.adhoc, 2025
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-08-11 15:47+0000\n"
"POT-Creation-Date: 2025-11-25 12:46+0000\n"
"PO-Revision-Date: 2025-08-11 15:47+0000\n"
"Last-Translator: Juan José Scarafía <scarafia.juanjose@gmail.com>, 2025\n"
"Last-Translator: migration.bot.adhoc, 2025\n"
"Language-Team: Spanish (https://app.transifex.com/adhoc/teams/46451/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -108,6 +109,11 @@ msgstr ""
msgid "Select to define the analytics account"
msgstr ""

#. module: purchase_order_type_ux
#: model:ir.model.fields,field_description:purchase_order_type_ux.field_purchase_order_line__taxes_id
msgid "Taxes"
msgstr "Impuestos"

#. module: purchase_order_type_ux
#: model:ir.model.fields,help:purchase_order_type_ux.field_purchase_order_type__picking_type_id
msgid "This will determine operation type of incoming shipment"
Expand Down
7 changes: 4 additions & 3 deletions purchase_order_type_ux/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ def _compute_invoice_payment_term_id(self):
def _compute_journal_id(self):
res = super()._compute_journal_id()
for move in self.filtered("purchase_type_id.journal_id"):
move.journal_id = move.purchase_type_id.journal_id
if move.purchase_type_id.journal_id:
move._onchange_journal()
if move.purchase_type_id.journal_id.company_id.id == move.company_id.id:
move.journal_id = move.purchase_type_id.journal_id
if move.purchase_type_id.journal_id:
move._onchange_journal()
return res

@api.onchange("journal_id")
Expand Down
41 changes: 26 additions & 15 deletions purchase_order_type_ux/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@api.model_create_multi
def create(self, vals):
res = super().create(vals)
if res.order_type and res.order_type.fiscal_position_id:
res.fiscal_position_id = res.order_type.fiscal_position_id
return res

@api.onchange("order_type")
def onchange_order_type(self):
super().onchange_order_type()
Expand All @@ -15,15 +22,16 @@ def onchange_order_type(self):
order.project_id = order.order_type.project_id
if order.order_type.picking_type_id:
order.picking_type_id = order.order_type.picking_type_id
if order.order_type.fiscal_position_id:
order.fiscal_position_id = order.order_type.fiscal_position_id

def _prepare_invoice(self):
if not self.order_type.journal_id:
return super()._prepare_invoice()
res = super()._prepare_invoice()
company = self.order_type.journal_id.company_id
self = self.with_company(company.id)
journal = self.env["account.journal"].browse(res.get("journal_id")) if res.get("journal_id") else False
if company != self.company_id:
res["company_id"] = company.id
# En purchase, partner_bank_id es del proveedor, no de la compañía
partner_bank_id = self.partner_id.commercial_partner_id.bank_ids.filtered_domain(
["|", ("company_id", "=", False), ("company_id", "=", company.id)]
Expand All @@ -32,15 +40,9 @@ def _prepare_invoice(self):
# agregamos para que recompute term y cond si la nueva compañia los tiene por defecto
if "narration" in res and not res["narration"]:
del res["narration"]
po_fiscal_position = self.env["account.fiscal.position"].browse(res["fiscal_position_id"])
if not po_fiscal_position or (po_fiscal_position.company_id and po_fiscal_position.company_id != company):
partner_invoice = self.env["res.partner"].browse(self.partner_id.address_get(["invoice"])["invoice"])
res["fiscal_position_id"] = (
self.env["account.fiscal.position"]
.with_company(company.id)
._get_fiscal_position(partner_invoice)
.id
)
if journal and journal.company_id.id != self.company_id.id:
res.pop("journal_id")

if self.order_type:
res["purchase_type_id"] = self.order_type.id
return res
Expand All @@ -53,8 +55,17 @@ def action_create_invoice(self):
"""
action = super().action_create_invoice()
invoices = self.invoice_ids.filtered(lambda m: m.state == "draft")
for line in invoices.invoice_line_ids:
purchase_line = line.purchase_line_id
if purchase_line and line.move_id.company_id != purchase_line.order_id.company_id:
line.tax_ids = line._get_computed_taxes()
for invoice in invoices.filtered("purchase_type_id.journal_id"):
company = invoice.purchase_type_id.journal_id.company_id
if invoice.company_id != company:
acc = self.env["account.change.company"].create(
{
"move_id": invoice.id,
"company_ids": [invoice.company_id.id, company.id],
"company_id": company.id,
"journal_id": invoice.purchase_type_id.journal_id.id,
}
)
acc.change_company()
invoice.partner_bank_id = company.partner_id.bank_ids[:1].id
return action
26 changes: 12 additions & 14 deletions purchase_order_type_ux/models/purchase_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ def _prepare_account_move_line(self, move=False):
"""
Forzamos compania de diario de purchase type
"""
if not self.order_id.order_type.journal_id:
return super()._prepare_account_move_line(move=move)
company = self.order_id.order_type.journal_id.company_id
self = self.with_company(company.id)
res = super()._prepare_account_move_line(move=move)

if company != self.company_id:
# Because we not have the access to the invoice, we obtain the fiscal position who
# has the invoice really
partner_invoice = self.env["res.partner"].browse(self.partner_id.address_get(["invoice"])["invoice"])
fpos = self.env["account.fiscal.position"].with_company(company.id)._get_fiscal_position(partner_invoice)
taxes = self.product_id.supplier_taxes_id.filtered(lambda r: company == r.company_id)
taxes = fpos.map_tax(taxes) if fpos else taxes

res["tax_ids"] = [(6, 0, taxes.ids)]
downpayment_lines = self.invoice_lines.filtered("is_downpayment")
account_id = self.env["account.account"].browse(res["account_id"]) if res.get("account_id") else None
if (
self.is_downpayment
and downpayment_lines
and account_id
and self.company_id.id not in account_id.company_ids.ids
):
account_id = self.env["account.change.company"]._get_change_downpayment_account(
self.company_id, self.invoice_lines, self.order_id.fiscal_position_id
)
res["account_id"] = account_id.id
return res
7 changes: 7 additions & 0 deletions purchase_order_type_ux/models/purchase_order_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class PurchaseOrderType(models.Model):
domain="['|', ('warehouse_id', '=', False), ('warehouse_id.company_id', '=', company_id)]",
help="This will determine operation type of incoming shipment",
)
fiscal_position_id = fields.Many2one(
"account.fiscal.position",
string="Fiscal Position",
check_company=True,
help="If you choose a fiscal position then this fiscal positioon would be used as default instead of the "
"automatically detected or setted on the partner",
)

@api.constrains("partner_id")
def _compute_partner_purchase_order_type(self):
Expand Down
3 changes: 3 additions & 0 deletions purchase_order_type_ux/views/purchase_order_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<field name="arch" type="xml">
<field name="payment_term_id" position="before">
<field name="journal_id" />
<field name="fiscal_position_id" />
</field>
</field>
</record>
Expand All @@ -23,6 +24,7 @@
<field name="project_id" />
<field name="journal_id" />
<field name="purchase_method" />
<field name="fiscal_position_id" string="Fiscal Position" />
</xpath>
</field>
</record>
Expand All @@ -37,6 +39,7 @@
<field name="partner_id"/>
<field name="picking_type_id"/>
<field name="journal_id"/>
<field name="fiscal_position_id"/>
</xpath>
<xpath expr="//group" position="inside">
<filter
Expand Down
6 changes: 3 additions & 3 deletions purchase_stock_ux/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# Juan José Scarafía <scarafia.juanjose@gmail.com>, 2024
# María Florencia Frigieri Parma, 2025
# Matias Velazquez, 2025
# ADHOC - Bot <transbot@adhoc.com.ar>, 2025
# migration.bot.adhoc, 2025
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-11-03 02:38+0000\n"
"POT-Creation-Date: 2025-11-28 02:43+0000\n"
"PO-Revision-Date: 2024-11-20 17:23+0000\n"
"Last-Translator: ADHOC - Bot <transbot@adhoc.com.ar>, 2025\n"
"Last-Translator: migration.bot.adhoc, 2025\n"
"Language-Team: Spanish (https://app.transifex.com/adhoc/teams/46451/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down