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
2 changes: 1 addition & 1 deletion l10n_ar_website_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'e-Commerce Argentina Partner Document',
'version': '11.0.1.3.1',
'version': '11.0.1.3.2',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
Expand Down
72 changes: 27 additions & 45 deletions l10n_ar_website_sale/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,62 +20,44 @@ def _get_mandatory_billing_fields(self):
]

def _checkout_form_save(self, mode, checkout, all_values):
# Extract data from commercial partner
post_process = False
commercial_partner_id = all_values.get('commercial_partner_id', False)
if commercial_partner_id:
commercial_partner, commercial_fields, values = \
request.env['res.partner'].sudo().get_commercial_data(
all_values)
if commercial_partner:
post_process = True
commercial_fields = [
'main_id_number',
'main_id_category_id',
'afip_responsability_type_id',
]
values = {}
for item in commercial_fields:
values.update({
item: checkout.pop(item, all_values.pop(item))
})
checkout.pop(item, False)
all_values.pop(item, False)

res = super(L10nArWebsiteSale, self)._checkout_form_save(
mode=mode, checkout=checkout, all_values=all_values)

# Write data on commercial partner
if post_process:
commercial_partner = request.env['res.partner'].browse(
int(commercial_partner_id))
values = self.remove_readonly_required_fields(
commercial_partner, commercial_fields, values)
if values:
if commercial_partner and values:
commercial_partner.sudo().write(values)
return res

def remove_readonly_required_fields(
self, record, required_fields, values):
""" In some cases we have information showed to the user in the form
that is required but that is already set and reaadonly.
We do not really update this fields and then here we are trying to
write them: the problem is that this fields has a constraint if
we are trying to re-write them (even when is the same value).

This method remove this (field, values) for the values to write in
order to do avoid the constraint and not re-writed again when they
has been already writed.

param: @record (recordset) the recorset to compore
param: @required_fields: (list) fields of the fields that we want to
check
param: @values (dict) the values of the web form

return: the same values to write and they do not include
required/readonly fields.
"""
for r_field in required_fields:
value = values.get(r_field)
if r_field.endswith('_id'):
if str(record[r_field].id) == value:
values.pop(r_field, False)
else:
if record[r_field] == value:
values.pop(r_field, False)
return values
def checkout_form_validate(self, mode, all_form_values, data):
error, error_message = super(
L10nArWebsiteSale, self).checkout_form_validate(
mode=mode, all_form_values=all_form_values, data=data)

# Validate commercial partner
main_id_number = data.get('main_id_number', all_form_values)
main_id_category_id = data.get('main_id_category_id', all_form_values)
if main_id_number and main_id_category_id:
commercial_partner, _commercial_fields, values = \
request.env['res.partner'].sudo().get_commercial_data(
all_form_values, data)
exc_error, exc_message = \
commercial_partner.sudo().catch_number_id_exceptions(values)
if exc_error:
error.update(exc_error)
error_message.extend(exc_message)
return error, error_message

@route()
def address(self, **kw):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<template id="product" name="Product" inherit_id="website_sale.product_price">
<xpath expr="//b[hasclass('oe_price')]" position="after">
<t t-if="vat_discriminated == True">
<span style="white-space: nowrap; font-size:medium; padding-left: 10px" t-esc="'(+' + product.sudo().vat_tax_id.name + ')'"/>
<span style="white-space: nowrap; font-size:medium; padding-left: 10px" t-esc="'(+' + 'dummy)'"/>
</t>
</xpath>
</template>
Expand Down
5 changes: 2 additions & 3 deletions l10n_ar_website_sale/wizards/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ class ResConfigSettings(models.TransientModel):
@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
res.update(
sale_use_taxes_default=
res.update({'sale_use_taxes_default':
self.env['ir.config_parameter'].sudo().get_param(
'l10n_ar_website_sale.sale_use_taxes_default', 'b2c'),
)
})
return res

@api.multi
Expand Down