-
-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][MIG] company_default_partner_pricelist #1946
Open
geomer198
wants to merge
12
commits into
OCA:16.0
Choose a base branch
from
cetmix:16.0-t4218-company_default_partner_pricelist-mig
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+747
−0
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6806ba3
[ADD] company_default_partner_pricelist
JordiMForgeFlow 33fbccf
[UPD] Update company_default_partner_pricelist.pot
c4f30da
[UPD] README.rst
OCA-git-bot deb2641
[UPD] README.rst
OCA-git-bot d5298a9
[FIX] company_default_partner_pricelist
SergiCForgeFlow a5775d5
[UPD] Update company_default_partner_pricelist.pot
af8b2ec
[BOT] post-merge updates
OCA-git-bot cb3dcf7
[IMP] company_default_partner_pricelist: pre-commit stuff
geomer198 ffbfa74
[MIG] company_default_partner_pricelist: Migration to 16.0
geomer198 f7af53d
[FIX] company_default_partner_pricelist: old migration script is removed
geomer198 cffc7b1
[IMP] company_default_partner_pricelist: readme is updated
geomer198 d48a280
[FIX] company_default_partner_pricelist: field name is updated
geomer198 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
================================= | ||
Company Default Partner Pricelist | ||
================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:0f3bf1f33bb78d925a93f4930fc19d1354f4c7d93aa48a1450d46f1f4e181bd1 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |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-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github | ||
:target: https://github.com/OCA/partner-contact/tree/16.0/company_default_partner_pricelist | ||
:alt: OCA/partner-contact | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-company_default_partner_pricelist | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
If the pricelist of a partner is not explicitly set, Odoo will try by default | ||
to find a valid pricelist based on the country of the partner. | ||
|
||
This module allows assigning a default pricelist for each company in the system | ||
to use as the default pricelist for partners. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To Configure the default company Pricelist: | ||
|
||
- Go to **General Settings** -> **Companies** | ||
- Press the **"Update Info"** button | ||
- On the Company form view, please select a pricelist for a company in the **"Default Account Pricelist"** field | ||
|
||
Usage | ||
===== | ||
|
||
To use this module simply assign a default pricelist to the companies for | ||
which you want to have a specific default value. | ||
|
||
If no default pricelist is assigned, the standard logic will apply. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20company_default_partner_pricelist%0Aversion:%2016.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 | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* ForgeFlow | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `ForgeFlow <https://www.forgeflow.com>` | ||
|
||
* Jordi Masvidal | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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. | ||
|
||
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/16.0/company_default_partner_pricelist>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 ForgeFlow, S.L. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Company Default Partner Pricelist", | ||
"summary": """ | ||
Define default partner pricelist per company. | ||
""", | ||
"version": "16.0.1.0.0", | ||
"author": "ForgeFlow, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/partner-contact", | ||
"category": "Partner Management", | ||
"depends": ["product"], | ||
"data": ["views/res_company_views.xml"], | ||
"installable": True, | ||
"license": "LGPL-3", | ||
} |
29 changes: 29 additions & 0 deletions
29
company_default_partner_pricelist/i18n/company_default_partner_pricelist.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * company_default_partner_pricelist | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \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: company_default_partner_pricelist | ||
#: model:ir.model,name:company_default_partner_pricelist.model_res_company | ||
msgid "Companies" | ||
msgstr "" | ||
|
||
#. module: company_default_partner_pricelist | ||
#: model:ir.model.fields,field_description:company_default_partner_pricelist.field_res_company__default_property_product_pricelist | ||
msgid "Default Account Pricelist" | ||
msgstr "" | ||
|
||
#. module: company_default_partner_pricelist | ||
#: model:ir.model.fields,help:company_default_partner_pricelist.field_res_company__default_property_product_pricelist | ||
msgid "Default pricelist for this company for new partners." | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import res_company |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,59 @@ | ||||||
# Copyright 2023 ForgeFlow, S.L. | ||||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||||||
from odoo import fields, models | ||||||
|
||||||
|
||||||
class ResCompany(models.Model): | ||||||
_inherit = "res.company" | ||||||
|
||||||
default_property_product_pricelist = fields.Many2one( | ||||||
"product.pricelist", | ||||||
string="Default Account Pricelist", | ||||||
help="Default pricelist for this company for new partners.", | ||||||
) | ||||||
|
||||||
def _update_partner_pricelist_generic_property(self): | ||||||
self.ensure_one() | ||||||
default_property_pp = self.default_property_product_pricelist | ||||||
ir_property = self.env["ir.property"] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and maybe set it with |
||||||
field = self.env["ir.model.fields"]._get( | ||||||
"res.partner", "property_product_pricelist" | ||||||
) | ||||||
ppty = ir_property.sudo().search( | ||||||
[ | ||||||
("name", "=", "property_product_pricelist"), | ||||||
("company_id", "=", self.id), | ||||||
("fields_id", "=", field.id), | ||||||
("res_id", "=", False), | ||||||
], | ||||||
limit=1, | ||||||
) | ||||||
if ppty: | ||||||
if not default_property_pp: | ||||||
ppty.sudo().unlink() | ||||||
else: | ||||||
ppty.sudo().write( | ||||||
{"value_reference": "product.pricelist,%s" % default_property_pp.id} | ||||||
) | ||||||
elif default_property_pp: | ||||||
ir_property.sudo().create( | ||||||
{ | ||||||
"name": "property_product_pricelist", | ||||||
"value_reference": "product.pricelist,%s" % default_property_pp.id, | ||||||
"fields_id": field.id, | ||||||
"company_id": self.id, | ||||||
} | ||||||
) | ||||||
|
||||||
def create(self, vals): | ||||||
res = super(ResCompany, self).create(vals) | ||||||
if "default_property_product_pricelist" in vals: | ||||||
res._update_partner_pricelist_generic_property() | ||||||
return res | ||||||
|
||||||
def write(self, vals): | ||||||
res = super(ResCompany, self).write(vals) | ||||||
if "default_property_product_pricelist" in vals: | ||||||
for rec in self: | ||||||
rec._update_partner_pricelist_generic_property() | ||||||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
To Configure the default company Pricelist: | ||
|
||
- Go to **General Settings** -> **Companies** | ||
- Press the **"Update Info"** button | ||
- On the Company form view, please select a pricelist for a company in the **"Default Account Pricelist"** field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* `ForgeFlow <https://www.forgeflow.com>` | ||
|
||
* Jordi Masvidal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
If the pricelist of a partner is not explicitly set, Odoo will try by default | ||
to find a valid pricelist based on the country of the partner. | ||
|
||
This module allows assigning a default pricelist for each company in the system | ||
to use as the default pricelist for partners. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
To use this module simply assign a default pricelist to the companies for | ||
which you want to have a specific default value. | ||
|
||
If no default pricelist is assigned, the standard logic will apply. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should have a subfix as
_id
formany2one