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
26 changes: 16 additions & 10 deletions product_contract/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-24 14:18+0000\n"
"PO-Revision-Date: 2025-01-24 15:19+0100\n"
"POT-Creation-Date: 2026-01-19 16:41+0000\n"
"PO-Revision-Date: 2026-01-19 17:45+0100\n"
"Last-Translator: Pedro M. Baeza <pedro.baeza@gmail.com>\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Poedit 3.0.1\n"
"X-Generator: Poedit 3.4.2\n"

#. module: product_contract
#. odoo-python
Expand Down Expand Up @@ -71,6 +71,12 @@ msgstr "Auto-renovación"
msgid "Automatically Create Contracts At Sale Order Confirmation"
msgstr "Crear Contratos Automáticamente en la Confirmación del Pedido de Venta"

#. module: product_contract
#: model:ir.model.fields,field_description:product_contract.field_product_contract_configurator__avoid_create_contract
#: model:ir.model.fields,field_description:product_contract.field_sale_order_line__avoid_create_contract
msgid "Avoid Create Contract"
msgstr "Evitar crear contrato"

#. module: product_contract
#: model_terms:ir.ui.view,arch_db:product_contract.product_contract_configurator_form
msgid "Cancel"
Expand Down Expand Up @@ -101,7 +107,7 @@ msgstr "Configurar un contrato"
#: code:addons/product_contract/static/src/xml/sale_product_field.xml:0
#, python-format
msgid "Configure contract"
msgstr ""
msgstr "Configurar contrato"

#. module: product_contract
#: model:ir.model,name:product_contract.model_contract_contract
Expand Down Expand Up @@ -153,7 +159,7 @@ msgstr "El producto del contrato debe ser del tipo de servicio"
#. module: product_contract
#: model_terms:ir.ui.view,arch_db:product_contract.product_contract_configurator_form
msgid "Contract renew"
msgstr ""
msgstr "Renovación de contrato"

#. module: product_contract
#: model_terms:ir.ui.view,arch_db:product_contract.view_order_form
Expand Down Expand Up @@ -268,7 +274,7 @@ msgstr "Cuarto mes"
#. module: product_contract
#: model:ir.model.fields,field_description:product_contract.field_product_contract_configurator__id
msgid "ID"
msgstr ""
msgstr "ID"

#. module: product_contract
#: model:ir.model.fields,field_description:product_contract.field_product_contract_configurator__recurring_interval
Expand All @@ -284,7 +290,7 @@ msgstr "Factura Cada"
#: model:ir.model.fields,help:product_contract.field_product_contract_configurator__recurring_interval
#: model:ir.model.fields,help:product_contract.field_sale_order_line__recurring_interval
msgid "Invoice every (Days/Week/Month/Year)"
msgstr ""
msgstr "Facturar cada (días/semana/mes/año)"

#. module: product_contract
#: model:ir.model.fields,field_description:product_contract.field_product_contract_configurator__recurring_invoicing_type
Expand Down Expand Up @@ -400,12 +406,12 @@ msgstr "Producto"
#. module: product_contract
#: model:ir.model,name:product_contract.model_product_contract_configurator
msgid "Product Contract Configurator Wizard"
msgstr ""
msgstr "Asistente de configuración del producto contrato"

#. module: product_contract
#: model:ir.model.fields,field_description:product_contract.field_sale_order_line__product_contract_description
msgid "Product Contract Description"
msgstr ""
msgstr "Descripción del producto contrato"

#. module: product_contract
#: model:ir.model.fields,field_description:product_contract.field_product_contract_configurator__product_uom_qty
Expand Down Expand Up @@ -467,7 +473,7 @@ msgstr "La orden de venta y el contrato deben estar vinculados al mismo socio"
#. module: product_contract
#: model:ir.model,name:product_contract.model_sale_order
msgid "Sales Order"
msgstr ""
msgstr "Orden de venta"

#. module: product_contract
#: model:ir.model,name:product_contract.model_sale_order_line
Expand Down
8 changes: 8 additions & 0 deletions product_contract/i18n/product_contract.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-01-19 16:41+0000\n"
"PO-Revision-Date: 2026-01-19 16:41+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -64,6 +66,12 @@ msgstr ""
msgid "Automatically Create Contracts At Sale Order Confirmation"
msgstr ""

#. module: product_contract
#: model:ir.model.fields,field_description:product_contract.field_product_contract_configurator__avoid_create_contract
#: model:ir.model.fields,field_description:product_contract.field_sale_order_line__avoid_create_contract
msgid "Avoid Create Contract"
msgstr ""

#. module: product_contract
#: model_terms:ir.ui.view,arch_db:product_contract.product_contract_configurator_form
msgid "Cancel"
Expand Down
11 changes: 9 additions & 2 deletions product_contract/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def _compute_need_contract_creation(self):

@api.depends("order_line")
def _compute_is_contract(self):
self.is_contract = any(self.order_line.mapped("is_contract"))
self.is_contract = any(
self.order_line.filtered(lambda ol: not ol.avoid_create_contract).mapped(
"is_contract"
)
)

def _prepare_contract_value(self, contract_template):
self.ensure_one()
Expand All @@ -69,12 +73,15 @@ def action_create_contract(self):
lines_without_contract = self.env["sale.order.line"].browse()
for rec in self.filtered("is_contract"):
line_to_create_contract = rec.order_line.filtered(
lambda r: not r.contract_id and r.product_id.is_contract
lambda r: not r.contract_id
and r.product_id.is_contract
and not r.avoid_create_contract
)
line_to_create_contract._set_contract_line_start_date()
line_to_update_contract = rec.order_line.filtered(
lambda r: r.contract_id
and r.product_id.is_contract
and not r.avoid_create_contract
and r
not in r.contract_id.contract_line_ids.mapped("sale_order_line_id")
)
Expand Down
3 changes: 3 additions & 0 deletions product_contract/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class SaleOrderLine(models.Model):
product_contract_description = fields.Text(
compute="_compute_product_contract_description"
)
avoid_create_contract = fields.Boolean()

@api.constrains("contract_id")
def _check_contact_is_not_terminated(self):
Expand Down Expand Up @@ -227,6 +228,8 @@ def create_contract_line(self, contract):
contract_line = self.env["contract.line"]
predecessor_contract_line = False
for rec in self:
if rec.avoid_create_contract:
continue
if rec.contract_line_id:
# If the upsell/downsell line start at the same date or before
# the contract line to replace supposed to start, we cancel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class ProductContractConfiguratorController extends formView.Controller {
auto_renew_interval,
auto_renew_rule_type,
recurring_interval,
avoid_create_contract,
} = record.data;
return this.action.doAction({
type: "ir.actions.act_window_close",
Expand All @@ -36,6 +37,7 @@ export class ProductContractConfiguratorController extends formView.Controller {
auto_renew_interval,
auto_renew_rule_type,
recurring_interval,
avoid_create_contract,
},
},
});
Expand Down
2 changes: 2 additions & 0 deletions product_contract/static/src/js/sale_product_field.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ patch(SaleOrderLineProductField.prototype, {
default_is_auto_renew: this.props.record.data.is_auto_renew,
default_auto_renew_interval: this.props.record.data.auto_renew_interval,
default_auto_renew_rule_type: this.props.record.data.auto_renew_rule_type,
default_avoid_create_contract: this.props.record.data.avoid_create_contract,
};
},

Expand All @@ -78,6 +79,7 @@ patch(SaleOrderLineProductField.prototype, {
is_auto_renew: this.props.record.data.is_auto_renew,
auto_renew_interval: this.props.record.data.auto_renew_interval,
auto_renew_rule_type: this.props.record.data.auto_renew_rule_type,
avoid_create_contract: this.props.record.data.avoid_create_contract,
};
},

Expand Down
9 changes: 9 additions & 0 deletions product_contract/tests/test_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ def test_action_confirm(self):
self.assertEqual(contract_line.date_end, Date.to_date("2018-12-31"))
self.assertEqual(contract_line.recurring_next_date, Date.to_date("2018-01-31"))

def test_action_confirm_avoiding_create_contract(self):
"""It shouldn't create a contract for lines marked as avoid_create_contract"""
self.order_line1.is_auto_renew = True
self.order_line1.avoid_create_contract = True
self.sale.action_confirm()
contracts = self.sale.order_line.mapped("contract_id")
self.assertEqual(len(contracts), 1)
self.assertFalse(self.order_line1.contract_id)

def test_change_sale_company(self):
self.assertTrue(self.sale.company_id)
other_company = self.env["res.company"].create(
Expand Down
1 change: 1 addition & 0 deletions product_contract/views/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
optional="hide"
readonly="product_uom_readonly"
/>
<field name="avoid_create_contract" optional="hide" />
</xpath>
</field>
</record>
Expand Down
1 change: 1 addition & 0 deletions product_contract/wizards/product_contract_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ProductContractConfigurator(models.TransientModel):
contract_start_date_method = fields.Selection(
related="product_id.contract_start_date_method"
)
avoid_create_contract = fields.Boolean()

@api.depends("product_id", "company_id")
def _compute_contract_template_id(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
</group>
<separator colspan="4" string="Contract" />
<group colspan="2">
<field name="avoid_create_contract" />
<field
name="contract_id"
options='{"no_create": True}'
Expand Down