Skip to content

Commit

Permalink
[ADD] sale_partner_company
Browse files Browse the repository at this point in the history
  • Loading branch information
santostelmo committed Aug 22, 2024
1 parent 141616a commit 974f82c
Show file tree
Hide file tree
Showing 16 changed files with 663 additions and 0 deletions.
92 changes: 92 additions & 0 deletions sale_partner_company/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
=====================
sale partner companyy
=====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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%2Fmulti--company-lightgray.png?logo=github
:target: https://github.com/OCA/multi-company/tree/16.0/sale_partner_company
:alt: OCA/multi-company
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-sale_partner_company
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/multi-company&target_branch=16.0
:alt: Try me on Runboat

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

Allow to set the default selling company on a partner.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

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

On the partner, choose the default company.

Create a sale.order with this partner, the sales company will be adapted from the partner.

Usage
=====

You need at least to manage 2 different companies.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/multi-company/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/multi-company/issues/new?body=module:%20sale_partner_company%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
~~~~~~~

* Camptocamp
* BCIM

Contributors
~~~~~~~~~~~~

* Telmo Santos <[email protected]>
* Jacques-Etienne Baudoux (BCIM) <[email protected]>

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/multi-company <https://github.com/OCA/multi-company/tree/16.0/sale_partner_company>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_partner_company/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions sale_partner_company/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "sale partner companyy",
"summary": "Set sale company from partner",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Sale Management",
"website": "https://github.com/OCA/multi-company",
"author": "Camptocamp, BCIM, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"data": [
"views/partner_view.xml",
],
"depends": [
"sale_stock",
"delivery",
],
}
2 changes: 2 additions & 0 deletions sale_partner_company/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_partner
from . import sale_order
14 changes: 14 additions & 0 deletions sale_partner_company/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

sale_company_id = fields.Many2one("res.company", string="Selling Company")

@api.model
def _commercial_fields(self):
return super()._commercial_fields() + ["sale_company_id"]
32 changes: 32 additions & 0 deletions sale_partner_company/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

company_id = fields.Many2one(
compute="_compute_company_id",
store=True,
precompute=True,
default=lambda self: self._get_default_company(),
)

def _get_default_company(self):
default_partner_id = self.env.context.get("default_partner_id")
if default_partner_id:
partner = self.env["res.partner"].browse(default_partner_id)
if partner.sale_company_id:
return partner.sale_company_id.id
else:
return self.env.company.id

@api.depends("partner_id.sale_company_id")
def _compute_company_id(self):
for sale in self:
if sale.partner_id.sale_company_id:
sale.company_id = sale.partner_id.sale_company_id
else:
sale.company_id = self.env.company
3 changes: 3 additions & 0 deletions sale_partner_company/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
On the partner, choose the default company.

Create a sale.order with this partner, the sales company will be adapted from the partner.
2 changes: 2 additions & 0 deletions sale_partner_company/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Telmo Santos <[email protected]>
* Jacques-Etienne Baudoux (BCIM) <[email protected]>
1 change: 1 addition & 0 deletions sale_partner_company/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow to set the default selling company on a partner.
1 change: 1 addition & 0 deletions sale_partner_company/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
You need at least to manage 2 different companies.
Loading

0 comments on commit 974f82c

Please sign in to comment.