Skip to content

Commit

Permalink
[WIP] Agrego cuotas en los items de producto
Browse files Browse the repository at this point in the history
  • Loading branch information
maq-adhoc committed Sep 19, 2022
1 parent 16b0178 commit bd20350
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 21 deletions.
1 change: 1 addition & 0 deletions website_sale_installment/__init__.py
@@ -1,2 +1,3 @@
from . import models
from . import controllers
from . import wizards
2 changes: 1 addition & 1 deletion website_sale_installment/__manifest__.py
Expand Up @@ -14,7 +14,7 @@
'data': [
'views/templates.xml',
'views/account_card.xml',
'views/res_config_setting.xml',
'wizards/res_config_setting.xml',
],
'assets': {
'web.assets_frontend': [
Expand Down
4 changes: 2 additions & 2 deletions website_sale_installment/models/product_template.py
Expand Up @@ -36,8 +36,8 @@ def _get_combination_info(self, combination=False, product_id=False, add_qty=1,
combination_info['installment_price'] = []
if self.env.context.get('website_id'):
website = self.env['website'].get_current_website()
if website.installment_price_id:
combination_info['installment_price'] = website.installment_price_id.card_installment_tree(combination_info['price'])
if website.installment_price_ids:
combination_info['installment_price'] = website.installment_price_ids.card_installment_tree(combination_info['price'])

return combination_info

17 changes: 3 additions & 14 deletions website_sale_installment/models/website.py
Expand Up @@ -5,18 +5,7 @@ class Website(models.Model):

_inherit = 'website'

installment_price_id = fields.Many2one(
'account.card.instalment',
string='Second price',
)


class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

installment_price_id = fields.Many2one(
'account.card.instalment',
string='Second price',
related='website_id.installment_price_id',
readonly=False
installment_price_ids = fields.Many2many(
'account.card.installment',
string='Installments',
)
38 changes: 36 additions & 2 deletions website_sale_installment/views/templates.xml
@@ -1,5 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="show_installment_prices" name="show installment prices" active="False" customize_show="True" inherit_id="website_sale.product_price" >
<xpath expr="//div/h3[2]" position="after">
<div t-foreach="combination_info['installment_price']" t-as="card">
<t t-foreach="combination_info['installment_price'][card]['installments']" t-as="line">
<div>
<t t-call="website_sale_installment.instalment_render_line">
<t t-set="inst" t-value="line"/>
</t>
</div>
</t>
</div>
</xpath>
</template>
<template id="item_show_installment_prices" name="show installment prices" active="False" customize_show="True" inherit_id="website_sale.products_item">
<xpath expr="//div[hasclass('product_price')]" position="after">
<div t-foreach="combination_info['installment_price']" t-as="card">
<t t-foreach="combination_info['installment_price'][card]['installments']" t-as="line">
<div>
<t t-call="website_sale_installment.instalment_render_line">
<t t-set="inst" t-value="line"/>
</t>
</div>
</t>
</div>
</xpath>
</template>

<template id="show_installment" name="show installment button" active="False" customize_show="True" inherit_id="website_sale.product_price" >
<xpath expr="//div/h3[2]" position="after">
<div class="js_card">
Expand All @@ -25,7 +52,6 @@
</div>
</t>
</template>

<template id="product_installment_form" name="Intallment form">
<div class="card">
<div class="card-body">
Expand Down Expand Up @@ -55,6 +81,14 @@
) </i>
</li>
</ul>

</template>
<template id="instalment_render_line">
<span t-if="inst['name'].isnumeric() and inst['divisor']==1">Un pago de </span>
<span t-elif="inst['name'].isnumeric() and inst['divisor']>1"><span t-esc="inst['divisor']"/> cuotas de </span>
<span t-elif="not inst['name'].isnumeric()"><span t-esc="inst['name']"/> cuotas de </span>
<span t-esc="inst['amount'] / inst['divisor']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
<i t-if="inst['divisor']>1"> (total
<span t-esc="inst['amount']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
) </i>
</template>
</odoo>
1 change: 1 addition & 0 deletions website_sale_installment/wizards/__init__.py
@@ -0,0 +1 @@
from . import res_config_settings
Expand Up @@ -11,12 +11,12 @@
<div class="row mt16 o_settings_container" id="sale_pricing_settings">
<div class="col-12 col-lg-6 o_setting_box" id="price_id_setting">
<div class="o_setting_right_pane">
<label for="installment_price_id" string="Installment price"/>
<label for="installment_price_ids" string="Installment price"/>
<div class="text-muted">Installment price
</div>
<div class="content-group">
<div class="mt16">
<field name="installment_price_id"/>
<field name="installment_price_ids" widget="many2many_tags"/>
</div>
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions website_sale_installment/wizards/res_config_settings.py
@@ -0,0 +1,12 @@
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

installment_price_ids = fields.Many2many(
'account.card.installment',
string='Installments',
related='website_id.installment_price_ids',
readonly=False
)

0 comments on commit bd20350

Please sign in to comment.