Browse Source

[IMP] event_sale_balance + [I18N]

16.0
RemiFr82 11 months ago
parent
commit
c48071b54d
  1. 1
      event_sale_balance/__manifest__.py
  2. 49
      event_sale_balance/i18n/fr.po
  3. 85
      event_sale_balance/models/product_template.py
  4. 7
      event_sale_balance/views/product_product.xml
  5. 20
      event_sale_balance/views/product_template.xml

1
event_sale_balance/__manifest__.py

@ -28,6 +28,7 @@
],
"data": [
"views/product_product.xml",
"views/product_template.xml",
],
"css": [],
"images": [],

49
event_sale_balance/i18n/fr.po

@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * event_sale_balance
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e-20230613\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-13 13:10+0000\n"
"PO-Revision-Date: 2024-01-13 13:10+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: event_sale_balance
#: model:ir.model.fields,field_description:event_sale_balance.field_product_product__balance_variant_id
#: model:ir.model.fields,field_description:event_sale_balance.field_product_template__balance_variant_id
msgid "Balance variant"
msgstr "Article de solde"
#. module: event_sale_balance
#: model:ir.model,name:event_sale_balance.model_event_registration
msgid "Event Registration"
msgstr "Inscription à l'événement"
#. module: event_sale_balance
#: model:ir.model.fields,field_description:event_sale_balance.field_product_product__is_event_deposit
#: model:ir.model.fields,field_description:event_sale_balance.field_product_template__is_event_deposit
msgid "Event deposit"
msgstr "Arrhe d'évènement"
#. module: event_sale_balance
#: model_terms:ir.ui.view,arch_db:event_sale_balance.product_template_form_view_inherit
#: model_terms:ir.ui.view,arch_db:event_sale_balance.product_variant_easy_edit_view_inherit
msgid "Event sale"
msgstr "Ventes sur évènements"
#. module: event_sale_balance
#: model:ir.model,name:event_sale_balance.model_product_template
msgid "Product"
msgstr "Produit"
#. module: event_sale_balance
#: model:ir.model,name:event_sale_balance.model_product_product
msgid "Product Variant"
msgstr "Variante de produit"

85
event_sale_balance/models/product_template.py

@ -1,8 +1,87 @@
from odoo import models, fields
from odoo import models, fields, api
class ProductTemplate(models.Model):
_inherit = "product.template"
is_event_deposit = fields.Boolean("Event deposit")
balance_variant_id = fields.Many2one("product.product", string="Balance variant")
is_event_deposit = fields.Boolean(
string="Event deposit",
compute="_compute_is_event_deposit",
inverse="_set_is_event_deposit",
search="_search_is_event_deposit",
)
balance_variant_id = fields.Many2one(
comodel_name="product.product",
string="Balance variant",
compute="_compute_balance_variant_id",
inverse="_set_balance_variant_id",
search="_search_balance_variant_id",
)
@api.depends("product_variant_ids.is_event_deposit")
def _compute_is_event_deposit(self):
self.is_event_deposit = False
for template in self:
variant_count = len(template.product_variant_ids)
if variant_count == 1:
template.is_event_deposit = (
template.product_variant_ids.is_event_deposit
)
elif variant_count == 0:
archived_variants = template.with_context(
active_test=False
).product_variant_ids
if len(archived_variants) == 1:
template.is_event_deposit = archived_variants.is_event_deposit
def _search_is_event_deposit(self, operator, value):
query = self.with_context(active_test=False)._search(
[("product_variant_ids.is_event_deposit", operator, value)]
)
return [("id", "in", query)]
def _set_is_event_deposit(self):
variant_count = len(self.product_variant_ids)
if variant_count == 1:
self.product_variant_ids.is_event_deposit = self.is_event_deposit
elif variant_count == 0:
archived_variants = self.with_context(active_test=False).product_variant_ids
if len(archived_variants) == 1:
archived_variants.is_event_deposit = self.is_event_deposit
@api.depends("product_variant_ids.balance_variant_id")
def _compute_balance_variant_id(self):
self.balance_variant_id = False
for template in self:
variant_count = len(template.product_variant_ids)
if variant_count == 1:
template.balance_variant_id = (
template.product_variant_ids.balance_variant_id
)
elif variant_count == 0:
archived_variants = template.with_context(
active_test=False
).product_variant_ids
if len(archived_variants) == 1:
template.balance_variant_id = archived_variants.balance_variant_id
def _search_balance_variant_id(self, operator, value):
query = self.with_context(active_test=False)._search(
[("product_variant_ids.balance_variant_id", operator, value)]
)
return [("id", "in", query)]
def _set_balance_variant_id(self):
variant_count = len(self.product_variant_ids)
if variant_count == 1:
self.product_variant_ids.balance_variant_id = self.balance_variant_id
elif variant_count == 0:
archived_variants = self.with_context(active_test=False).product_variant_ids
if len(archived_variants) == 1:
archived_variants.balance_variant_id = self.balance_variant_id
def _get_related_fields_variant_template(self):
return super()._get_related_fields_variant_template() + [
"is_event_deposit",
"balance_variant_id",
]

7
event_sale_balance/views/product_product.xml

@ -12,13 +12,14 @@
<group name="product_variant_images" position="after">
<group name="event" string="Event sale" attrs="{'invisible': [('detailed_type','!=','event')]}">
<field name="is_event_deposit" />
<field name="balance_variant_id" options="{'no_create': 1}" />
<field name="balance_variant_id" options="{'no_create': 1}"
attrs="{'invisible':[('is_event_deposit','=',False)],'required':[('is_event_deposit','=',True)]}" />
</group>
</group>
</field>
</record>
<record id="product_normal_form_view_inherit" model="ir.ui.view">
<!-- <record id="product_normal_form_view_inherit" model="ir.ui.view">
<field name="name">product.product.view.form.inherit</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view" />
@ -30,6 +31,6 @@
</group>
</group>
</field>
</record>
</record> -->
</odoo>

20
event_sale_balance/views/product_template.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_template_form_view_inherit" model="ir.ui.view">
<field name="name">product.template.common.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<group name="description" position="after">
<group name="event" string="Event sale"
attrs="{'invisible': ['|',('detailed_type','!=','event'),'&amp;',('product_variant_count','>', 1), ('is_product_variant', '=', False)]}">
<field name="is_event_deposit" />
<field name="balance_variant_id" options="{'no_create': 1}"
attrs="{'invisible':[('is_event_deposit','=',False)],'required':[('is_event_deposit','=',True)]}" />
</group>
</group>
</field>
</record>
</odoo>
Loading…
Cancel
Save