Skip to content

Commit

Permalink
[MIG] l10n_it_website_sale_corrispettivi: Migration to 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoRubi authored and eLBati committed Mar 30, 2019
1 parent 20b7b45 commit ed0fd0d
Show file tree
Hide file tree
Showing 14 changed files with 625 additions and 51 deletions.
104 changes: 78 additions & 26 deletions l10n_it_website_sale_corrispettivi/README.rst
Original file line number Diff line number Diff line change
@@ -1,62 +1,114 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

=================================================
Italian localization - Website Sale Corrispettivi
=================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-italy/tree/11.0/l10n_it_website_sale_corrispettivi
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-italy-11-0/l10n-italy-11-0-l10n_it_website_sale_corrispettivi
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/122/11.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

**Italiano**

Questo modulo aggiunge la spunta *Voglio fattura* nella pagina dell'indirizzo all'interno del flusso di checkout,
il suo valore è l'opposto di *Usa corrispettivi* nel partner.

Per gli utenti non loggati, il default del flag *Voglio fattura* è sempre vuoto.

**English**

This module adds the *Want invoice* check in partner's address form of checkout flow,
its value is the opposite of *Use corrispettivi* in partner.

For unlogged users the default value for *Want invoice* flag is always empty.

**Table of contents**

.. contents::
:local:

Configuration
=============

For unlogged users, the behavior depends on how the partner associated to the public user is configured
(note that the public user is an inactive user by default), for instance:
**Italiano**

Il comportamento dipende da come è configurato il partner associato all'utente loggato, ad esempio:

* Se il partner associato all'utente loggato ha il flag *Usa corrispettivi* abilitato, la spunta *Voglio fattura* sarà disabilitata;
* Se il partner associato all'utente loggato ha il flag *Usa corrispettivi* disabilitato, la spunta *Voglio fattura* sarà abilitata;

* If the public user has the flag *Use corrispettivi* enabled, the unlogged user will have *Want invoice* disabled;
* If the public user has the flag *Use corrispettivi* disabled, the unlogged user will have *Want invoice* enabled;
**English**

Usage
=====
The behavior depends on how the partner associated with the logged in user is configured, for example:

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/113/10.0
* If the partner associated with the logged in user has the *Use corrispettivi* flag enabled, the check *Want invoice* will be disabled;
* If the partner associated with the logged in user has the *Use corrispettivi* flag disabled, the check *Want invoice* will be enabled;


Known issues / Roadmap
======================

**Italiano**

Per gli utenti non loggati il default del flag *Voglio fattura* è sempre vuoto, dovrebbe dipendere dal flag *Usa corrispettivi* nel partner dell'utente pubblico.

**English**

For unlogged users the default value for *Want invoice* flag is always empty, it should depend on the *Use corrispettivi* flag in the partner of the public user.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/l10n_italy/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_website_sale_corrispettivi%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Images
------
Authors
~~~~~~~

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
* Agile Business Group

Contributors
------------
~~~~~~~~~~~~

* Simone Rubino <[email protected]>

Maintainer
----------
Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/11.0/l10n_it_website_sale_corrispettivi>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 0 additions & 1 deletion l10n_it_website_sale_corrispettivi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import controllers
Expand Down
5 changes: 2 additions & 3 deletions l10n_it_website_sale_corrispettivi/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

Expand All @@ -7,9 +6,9 @@
'category': 'e-commerce',
'author': 'Agile Business Group,'
'Odoo Community Association (OCA)',
'version': '10.0.1.1.1',
'version': '11.0.1.0.0',
'license': 'AGPL-3',
'website': 'https://github.com/OCA/l10n-italy/tree/10.0/'
'website': 'https://github.com/OCA/l10n-italy/tree/11.0/'
'l10n_it_website_sale_corrispettivi',
'depends': [
'website_sale',
Expand Down
1 change: 0 additions & 1 deletion l10n_it_website_sale_corrispettivi/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import main
45 changes: 27 additions & 18 deletions l10n_it_website_sale_corrispettivi/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.http import request
Expand All @@ -8,33 +7,39 @@
class WebsiteSaleCorrispettivi(WebsiteSale):

def _checkout_form_save(self, mode, checkout, all_values):
res = super(WebsiteSaleCorrispettivi, self) \
partner_id = super(WebsiteSaleCorrispettivi, self) \
._checkout_form_save(mode, checkout, all_values)
use_invoice = all_values.get('use_invoice')
# Update order

order = request.website.sale_get_order()
order_values = \
self._prepare_corrispettivi_order_values(order, use_invoice)
order.write(order_values)
# Update the order, note that has already been retrieved using sudo()
if order:
order_values = self._prepare_corrispettivi_order_values(
order, use_invoice)
order.sudo().write(order_values)

# Update partner
partner = request.env['res.partner'].browse(res)
partner_values = \
self._prepare_corrispettivi_partner_values(partner, use_invoice)
partner.sudo().write(partner_values)
return res
# Update the partner that has been created by the checkout form
partner = request.env['res.partner'].sudo().browse(partner_id)
partner_values = self._prepare_corrispettivi_partner_values(
partner, use_invoice)
partner.write(partner_values)
return partner_id

def _prepare_corrispettivi_partner_values(self, partner, use_invoice):
"""
:param partner: current partner, retrieved using sudo
:param use_invoice: if we have to use invoice or corrispettivi
fiscal position
"""
partner_values = {'use_corrispettivi': not use_invoice}
if not partner.property_account_position_id:
# No fiscal position: assign a corrispettivi fiscal position
# if requested
if not use_invoice:
company = partner.company_id or \
partner.default_get(['company_id'])['company_id']
company = partner.company_id
partner_values['property_account_position_id'] = \
request.env['account.fiscal.position'] \
.get_corr_fiscal_pos(company).id
.sudo().get_corr_fiscal_pos(company).id
else:
# There is a fiscal position:
# remove it only if it is a corrispettivi one
Expand All @@ -45,16 +50,20 @@ def _prepare_corrispettivi_partner_values(self, partner, use_invoice):
return partner_values

def _prepare_corrispettivi_order_values(self, order, use_invoice):
"""
:param order: current order, retrieved using sudo
:param use_invoice: if we have to use invoice or corrispettivi
fiscal position
"""
order_values = {'corrispettivi': not use_invoice}
if not order.fiscal_position_id:
# No fiscal position: assign a corrispettivi fiscal position
# if requested
if not use_invoice:
company = order.company_id or \
order.default_get(['company_id'])['company_id']
company = order.company_id
order_values['fiscal_position_id'] = \
request.env['account.fiscal.position'] \
.get_corr_fiscal_pos(company).id
.sudo().get_corr_fiscal_pos(company).id
else:
# There is a fiscal position:
# remove it only if it is a corrispettivi one
Expand Down
1 change: 0 additions & 1 deletion l10n_it_website_sale_corrispettivi/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import website
1 change: 0 additions & 1 deletion l10n_it_website_sale_corrispettivi/models/website.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

Expand Down
14 changes: 14 additions & 0 deletions l10n_it_website_sale_corrispettivi/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
**Italiano**

Il comportamento dipende da come è configurato il partner associato all'utente loggato, ad esempio:

* Se il partner associato all'utente loggato ha il flag *Usa corrispettivi* abilitato, la spunta *Voglio fattura* sarà disabilitata;
* Se il partner associato all'utente loggato ha il flag *Usa corrispettivi* disabilitato, la spunta *Voglio fattura* sarà abilitata;

**English**

The behavior depends on how the partner associated with the logged in user is configured, for example:

* If the partner associated with the logged in user has the *Use corrispettivi* flag enabled, the check *Want invoice* will be disabled;
* If the partner associated with the logged in user has the *Use corrispettivi* flag disabled, the check *Want invoice* will be enabled;

1 change: 1 addition & 0 deletions l10n_it_website_sale_corrispettivi/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Simone Rubino <[email protected]>
13 changes: 13 additions & 0 deletions l10n_it_website_sale_corrispettivi/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**Italiano**

Questo modulo aggiunge la spunta *Voglio fattura* nella pagina dell'indirizzo all'interno del flusso di checkout,
il suo valore è l'opposto di *Usa corrispettivi* nel partner.

Per gli utenti non loggati, il default del flag *Voglio fattura* è sempre vuoto.

**English**

This module adds the *Want invoice* check in partner's address form of checkout flow,
its value is the opposite of *Use corrispettivi* in partner.

For unlogged users the default value for *Want invoice* flag is always empty.
7 changes: 7 additions & 0 deletions l10n_it_website_sale_corrispettivi/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**Italiano**

Per gli utenti non loggati il default del flag *Voglio fattura* è sempre vuoto, dovrebbe dipendere dal flag *Usa corrispettivi* nel partner dell'utente pubblico.

**English**

For unlogged users the default value for *Want invoice* flag is always empty, it should depend on the *Use corrispettivi* flag in the partner of the public user.
Loading

0 comments on commit ed0fd0d

Please sign in to comment.