Skip to content

Commit

Permalink
[IMP] product: pricelist option in label printing
Browse files Browse the repository at this point in the history
before this commit, on printing product labels there
is no option to select the price list, always the
printed price is the default product price

after this commit, in the label printing wizard
the price list field is introduced and user can
select the price list before printing the labels

closes odoo#137190

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
  • Loading branch information
niyasraphy committed Oct 13, 2023
1 parent 3c72683 commit 168b56e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
1 change: 1 addition & 0 deletions addons/product/report/product_label_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def _prepare_data(env, data):
'page_numbers': (total - 1) // (layout_wizard.rows * layout_wizard.columns) + 1,
'price_included': data.get('price_included'),
'extra_html': layout_wizard.extra_html,
'pricelist': layout_wizard.pricelist_id,
}

class ReportProductTemplateLabel(models.AbstractModel):
Expand Down
32 changes: 8 additions & 24 deletions addons/product/report/product_product_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
<div class="o_label_extra_data">
<t t-out="extra_html"/>
</div>
<t t-if="product.is_product_variant">
<strong class="o_label_price" t-field="product.lst_price" t-options="{'widget': 'monetary', 'label_price': True}"/>
</t>
<t t-else="">
<strong class="o_label_price" t-field="product.list_price" t-options="{'widget': 'monetary', 'label_price': True}"/>
</t>
<strong class="o_label_price" t-out="pricelist._get_product_price(product, 1, pricelist.currency_id or product.currency_id)"
t-options="{'widget': 'monetary', 'display_currency': pricelist.currency_id or product.currency_id, 'label_price': True}"/>
</div>
<div class="o_label_clear"></div>
</div>
Expand All @@ -43,12 +39,8 @@
<strong t-field="product.display_name"/>
</div>
<div class="text-end" style="padding-top:0;padding-bottom:0">
<t t-if="product.is_product_variant">
<strong class="o_label_price_medium" t-field="product.lst_price" t-options="{'widget': 'monetary', 'label_price': True}"/>
</t>
<t t-else="">
<strong class="o_label_price_medium" t-field="product.list_price" t-options="{'widget': 'monetary', 'label_price': True}"/>
</t>
<strong class="o_label_price_medium" t-out="pricelist._get_product_price(product, 1, pricelist.currency_id or product.currency_id)"
t-options="{'widget': 'monetary', 'display_currency': pricelist.currency_id or product.currency_id, 'label_price': True}"/>
</div>
<div class= "text-center o_label_small_barcode">
<span class="text-nowrap" t-field="product.default_code"/>
Expand All @@ -74,12 +66,8 @@
<span class="text-nowrap" t-field="product.default_code"/>
</div>
<div class="o_label_price_medium text-end">
<t t-if="product.is_product_variant">
<strong t-field="product.lst_price" t-options="{'widget': 'monetary', 'label_price': True}"/>
</t>
<t t-else="">
<strong t-field="product.list_price" t-options="{'widget': 'monetary', 'label_price': True}"/>
</t>
<strong t-out="pricelist._get_product_price(product, 1, pricelist.currency_id or product.currency_id)"
t-options="{'widget': 'monetary', 'display_currency': pricelist.currency_id or product.currency_id, 'label_price': True}"/>
</div>
</t>
<t t-else="">
Expand Down Expand Up @@ -117,12 +105,8 @@
<small class="text-nowrap" t-field="product.default_code"/>
</div>
<div class="text-end" style="padding: 0 4px;">
<t t-if="product.is_product_variant">
<strong class="o_label_price_small" t-field="product.lst_price" t-options="{'widget': 'monetary', 'label_price': True}"/>
</t>
<t t-else="">
<strong class="o_label_price_small" t-field="product.list_price" t-options="{'widget': 'monetary', 'label_price': True}"/>
</t>
<strong class="o_label_price_small" t-out="pricelist._get_product_price(product, 1, pricelist.currency_id or product.currency_id)"
t-options="{'widget': 'monetary', 'display_currency': pricelist.currency_id or product.currency_id, 'label_price': True}"/>
<div class="o_label_extra_data">
<t t-out="extra_html"/>
</div>
Expand Down
1 change: 1 addition & 0 deletions addons/product/wizard/product_label_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ProductLabelLayout(models.TransientModel):
extra_html = fields.Html('Extra Content', default='')
rows = fields.Integer(compute='_compute_dimensions')
columns = fields.Integer(compute='_compute_dimensions')
pricelist_id = fields.Many2one('product.pricelist', string="Pricelist")

@api.depends('print_format')
def _compute_dimensions(self):
Expand Down
1 change: 1 addition & 0 deletions addons/product/wizard/product_label_layout_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<field name="print_format" widget="radio"/>
</group>
<group>
<field name="pricelist_id" groups="product.group_product_pricelist"/>
<field name="extra_html" widget="html" invisible="print_format not in ('dymo', '2x7xprice')"/>
</group>
</group>
Expand Down

0 comments on commit 168b56e

Please sign in to comment.