Skip to content
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

shopinvader_*_address: namming cleanup billing > invoicing and shipping > delivery #1442

Merged
merged 1 commit into from
Nov 3, 2023
Merged
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 shopinvader/i18n/shopinvader.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3361,7 +3361,7 @@ msgid "Shipped"
msgstr ""

#. module: shopinvader
#: model:ir.model.fields,field_description:shopinvader.field_shopinvader_partner__partner_delivery_id
#: model:ir.model.fields,field_description:shopinvader.field_shopinvader_partner__partner_shipping_id
msgid "Shipping address"
msgstr ""

Expand Down
22 changes: 11 additions & 11 deletions shopinvader_address/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Shopinvader Address
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:06873347bbdc39a1e46d9924aeab7bd3dc529f5fb19ad1ad91e9cdb308db3e30
!! source digest: sha256:4ae916f6e94ee5b35b87578e21fae8e7e2ee8cd049c406f3ae3820ff88d8901c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -33,35 +33,35 @@ and the creation of addresses within odoo code.
Usage
=====

BillingAddress
In the context of shopinvader, the ``BillingAddress`` corresponds to the authenticated partner itself.
Therefore, the ``Billing Address`` is unique for each partner.
InvoicingAddress
In the context of shopinvader, the ``InvoicingAddress`` corresponds to the authenticated partner itself.
Therefore, the ``Invoicing Address`` is unique for each partner.

Creation of ``Billing Address`` is not supported since it corresponds to the authenticated partner.
Creation of ``Invoicing Address`` is not supported since it corresponds to the authenticated partner.

It can be updated using:

.. code-block:: python

def _update_shopinvader_billing_address(self, vals: dict, address_id: int) -> "ResPartner"
def _update_shopinvader_invoicing_address(self, vals: dict, address_id: int) -> "ResPartner"

*Remark: it cannot be modified if it has already been used on a confirmed sale order.*

ShippingAddress
In the context of shopinvader, a ``ShippingAddress`` corresponds to any delivery address linked to the authenticated partner.
A partner can have between 0 and n ``ShippingAddress``.
DeliveryAddress
In the context of shopinvader, a ``DeliveryAddress`` corresponds to any delivery address linked to the authenticated partner.
A partner can have between 0 and n ``DeliveryAddress``.

It can be created using:

.. code-block:: python

def _create_shopinvader_shipping_address(self, vals: dict) -> "ResPartner":
def _create_shopinvader_delivery_address(self, vals: dict) -> "ResPartner":

It can be updated using:

.. code-block:: python

def _update_shopinvader_shipping_address(self, vals: dict, address_id: int) -> "ResPartner":
def _update_shopinvader_delivery_address(self, vals: dict, address_id: int) -> "ResPartner":

*Remark: it cannot be modified if it has already been used on a confirmed sale order.*

Expand Down
2 changes: 1 addition & 1 deletion shopinvader_address/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Shopinvader Address",
"summary": """
Shopinvader Address: Shipping,Billing""",
Shopinvader Address: Delivery,Invoicing""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV",
Expand Down
12 changes: 6 additions & 6 deletions shopinvader_address/i18n/shopinvader_address.pot
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ msgstr ""
#. odoo-python
#: code:addons/shopinvader_address/models/res_partner.py:0
#, python-format
msgid "Billing address not found, id: %(address_id)d"
msgid "Invoicing address not found, id: %(address_id)d"
msgstr ""

#. module: shopinvader_address
#. odoo-python
#: code:addons/shopinvader_address/models/res_partner.py:0
#, python-format
msgid ""
"Can not delete Shipping address(%(address_id)d)because it is already used on"
"Can not delete Delivery address(%(address_id)d)because it is already used on"
" confirmed sale order"
msgstr ""

Expand All @@ -34,7 +34,7 @@ msgstr ""
#: code:addons/shopinvader_address/models/res_partner.py:0
#, python-format
msgid ""
"Can not update billing addresses(%(address_id)d)because it is already used "
"Can not update invoicing addresses(%(address_id)d)because it is already used "
"on confirmed sale order"
msgstr ""

Expand All @@ -47,7 +47,7 @@ msgstr ""
#. odoo-python
#: code:addons/shopinvader_address/models/res_partner.py:0
#, python-format
msgid "Creation of billing addresses is not supported"
msgid "Creation of invoicing addresses is not supported"
msgstr ""

#. module: shopinvader_address
Expand All @@ -61,14 +61,14 @@ msgstr ""
#. odoo-python
#: code:addons/shopinvader_address/models/res_partner.py:0
#, python-format
msgid "Shipping address not found, id: %(address_id)d"
msgid "Delivery address not found, id: %(address_id)d"
msgstr ""

#. module: shopinvader_address
#. odoo-python
#: code:addons/shopinvader_address/models/res_partner.py:0
#, python-format
msgid ""
"parent_id and type cannot be modified on shopinvader shipping address, id: "
"parent_id and type cannot be modified on shopinvader delivery address, id: "
"%(address_id)d"
msgstr ""
66 changes: 33 additions & 33 deletions shopinvader_address/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class ResPartner(models.Model):

_inherit = "res.partner"

def _ensure_shopinvader_billing_address_not_used(self) -> None:
def _ensure_shopinvader_invoicing_address_not_used(self) -> None:
"""
Check if Billing Address is used on confirmed sale order
Check if Invoicing Address is used on confirmed sale order
"""
self.ensure_one()
sale_order = (
Expand All @@ -28,15 +28,15 @@ def _ensure_shopinvader_billing_address_not_used(self) -> None:
if len(sale_order) > 0:
raise UserError(
_(
"Can not update billing addresses(%(address_id)d)"
"Can not update invoicing addresses(%(address_id)d)"
"because it is already used on confirmed sale order",
address_id=self.id,
)
)

def _ensure_shopinvader_shipping_address_not_used(self) -> None:
def _ensure_shopinvader_delivery_address_not_used(self) -> None:
"""
Check if Shipping Address is used on confirmed sale order
Check if Delivery Address is used on confirmed sale order
"""
self.ensure_one()
sale_order = (
Expand All @@ -53,107 +53,107 @@ def _ensure_shopinvader_shipping_address_not_used(self) -> None:
if len(sale_order) > 0:
raise UserError(
_(
"Can not delete Shipping address(%(address_id)d)"
"Can not delete Delivery address(%(address_id)d)"
"because it is already used on confirmed sale order",
address_id=self.id,
)
)

# --- Billing ---
# Billing address is unique and corresponds to authenticated_partner
# --- Invoicing ---
# Invoicing address is unique and corresponds to authenticated_partner

def _get_shopinvader_billing_addresses(self) -> "ResPartner":
def _get_shopinvader_invoicing_addresses(self) -> "ResPartner":
self.ensure_one()
return self

def _get_shopinvader_billing_address(self, address_id: int) -> "ResPartner":
def _get_shopinvader_invoicing_address(self, address_id: int) -> "ResPartner":
self.ensure_one()
addresses = self._get_shopinvader_billing_addresses()
addresses = self._get_shopinvader_invoicing_addresses()
address = addresses.filtered(lambda rec: rec.id == address_id)
if not address:
raise MissingError(
_(
"Billing address not found, id: %(address_id)d",
"Invoicing address not found, id: %(address_id)d",
address_id=address_id,
)
)
return address

def _create_shopinvader_billing_address(self, vals: dict) -> "ResPartner":
raise UserError(_("Creation of billing addresses is not supported"))
def _create_shopinvader_invoicing_address(self, vals: dict) -> "ResPartner":
raise UserError(_("Creation of invoicing addresses is not supported"))

def _update_shopinvader_billing_address(
def _update_shopinvader_invoicing_address(
self, vals: dict, address_id: int
) -> "ResPartner":
self.ensure_one()
address = self._get_shopinvader_billing_address(address_id)
address = self._get_shopinvader_invoicing_address(address_id)

# if billing address is already used, it is not possible to modify it
# if invoicing address is already used, it is not possible to modify it
# an error will be raised
address._ensure_shopinvader_billing_address_not_used()
address._ensure_shopinvader_invoicing_address_not_used()

address.write(vals)

return address

# ---Shipping ---
# ---Delivery ---

def _get_shopinvader_shipping_addresses(self) -> "ResPartner":
def _get_shopinvader_delivery_addresses(self) -> "ResPartner":
self.ensure_one()
domain = [("type", "=", "delivery"), ("parent_id", "=", self.id)]

return self.env["res.partner"].search(domain)

def _get_shopinvader_shipping_address(self, address_id: int) -> "ResPartner":
def _get_shopinvader_delivery_address(self, address_id: int) -> "ResPartner":
self.ensure_one()

addresses = self._get_shopinvader_shipping_addresses()
addresses = self._get_shopinvader_delivery_addresses()
address = addresses.filtered(lambda rec: rec.id == address_id)
if not address:
raise MissingError(
_(
"Shipping address not found, id: %(address_id)d",
"Delivery address not found, id: %(address_id)d",
address_id=address_id,
)
)

return address

def _create_shopinvader_shipping_address(self, vals: dict) -> "ResPartner":
def _create_shopinvader_delivery_address(self, vals: dict) -> "ResPartner":
self.ensure_one()
vals = dict(vals, parent_id=self.id, type="delivery")
return self.env["res.partner"].create(vals)

def _update_shopinvader_shipping_address(
def _update_shopinvader_delivery_address(
self, vals: dict, address_id: int
) -> "ResPartner":

if any(key in vals for key in ("parent_id", "type")):
raise UserError(
_(
"parent_id and type cannot be modified on"
" shopinvader shipping address, id: %(address_id)d",
" shopinvader delivery address, id: %(address_id)d",
address_id=address_id,
)
)

self.ensure_one()
address = self._get_shopinvader_shipping_address(address_id)
address = self._get_shopinvader_delivery_address(address_id)

# if shipping address is already used, it is not possible to modify it
address._ensure_shopinvader_shipping_address_not_used()
# if delivery address is already used, it is not possible to modify it
address._ensure_shopinvader_delivery_address_not_used()

# update_address
address.write(vals)
return address

def _delete_shopinvader_shipping_address(self, address_id: int) -> None:
def _delete_shopinvader_delivery_address(self, address_id: int) -> None:
"""
Delete of shopinvader shipping addresses will result to an archive
Delete of shopinvader delivery addresses will result to an archive
"""
address = self._get_shopinvader_shipping_address(address_id)
address = self._get_shopinvader_delivery_address(address_id)
if address:
address._ensure_shopinvader_shipping_address_not_used()
address._ensure_shopinvader_delivery_address_not_used()

# archive address
address.active = False
Expand Down
20 changes: 10 additions & 10 deletions shopinvader_address/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
BillingAddress
In the context of shopinvader, the ``BillingAddress`` corresponds to the authenticated partner itself.
Therefore, the ``Billing Address`` is unique for each partner.
InvoicingAddress
In the context of shopinvader, the ``InvoicingAddress`` corresponds to the authenticated partner itself.
Therefore, the ``Invoicing Address`` is unique for each partner.

Creation of ``Billing Address`` is not supported since it corresponds to the authenticated partner.
Creation of ``Invoicing Address`` is not supported since it corresponds to the authenticated partner.

It can be updated using:

.. code-block:: python

def _update_shopinvader_billing_address(self, vals: dict, address_id: int) -> "ResPartner"
def _update_shopinvader_invoicing_address(self, vals: dict, address_id: int) -> "ResPartner"

*Remark: it cannot be modified if it has already been used on a confirmed sale order.*

ShippingAddress
In the context of shopinvader, a ``ShippingAddress`` corresponds to any delivery address linked to the authenticated partner.
A partner can have between 0 and n ``ShippingAddress``.
DeliveryAddress
In the context of shopinvader, a ``DeliveryAddress`` corresponds to any delivery address linked to the authenticated partner.
A partner can have between 0 and n ``DeliveryAddress``.

It can be created using:

.. code-block:: python

def _create_shopinvader_shipping_address(self, vals: dict) -> "ResPartner":
def _create_shopinvader_delivery_address(self, vals: dict) -> "ResPartner":

It can be updated using:

.. code-block:: python

def _update_shopinvader_shipping_address(self, vals: dict, address_id: int) -> "ResPartner":
def _update_shopinvader_delivery_address(self, vals: dict, address_id: int) -> "ResPartner":

*Remark: it cannot be modified if it has already been used on a confirmed sale order.*
22 changes: 11 additions & 11 deletions shopinvader_address/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Shopinvader Address</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:06873347bbdc39a1e46d9924aeab7bd3dc529f5fb19ad1ad91e9cdb308db3e30
!! source digest: sha256:4ae916f6e94ee5b35b87578e21fae8e7e2ee8cd049c406f3ae3820ff88d8901c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/shopinvader/odoo-shopinvader/tree/16.0/shopinvader_address"><img alt="shopinvader/odoo-shopinvader" src="https://img.shields.io/badge/github-shopinvader%2Fodoo--shopinvader-lightgray.png?logo=github" /></a></p>
<p>This addons adds helper methos on the res.partner model that ease the management
Expand All @@ -388,26 +388,26 @@ <h1 class="title">Shopinvader Address</h1>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<dl class="docutils">
<dt>BillingAddress</dt>
<dd><p class="first">In the context of shopinvader, the <tt class="docutils literal">BillingAddress</tt> corresponds to the authenticated partner itself.
Therefore, the <tt class="docutils literal">Billing Address</tt> is unique for each partner.</p>
<p>Creation of <tt class="docutils literal">Billing Address</tt> is not supported since it corresponds to the authenticated partner.</p>
<dt>InvoicingAddress</dt>
<dd><p class="first">In the context of shopinvader, the <tt class="docutils literal">InvoicingAddress</tt> corresponds to the authenticated partner itself.
Therefore, the <tt class="docutils literal">Invoicing Address</tt> is unique for each partner.</p>
<p>Creation of <tt class="docutils literal">Invoicing Address</tt> is not supported since it corresponds to the authenticated partner.</p>
<p>It can be updated using:</p>
<pre class="code python literal-block">
<span class="k">def</span> <span class="nf">_update_shopinvader_billing_address</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vals</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">address_id</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">&quot;ResPartner&quot;</span>
<span class="k">def</span> <span class="nf">_update_shopinvader_invoicing_address</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vals</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">address_id</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">&quot;ResPartner&quot;</span>
</pre>
<p class="last"><em>Remark: it cannot be modified if it has already been used on a confirmed sale order.</em></p>
</dd>
<dt>ShippingAddress</dt>
<dd><p class="first">In the context of shopinvader, a <tt class="docutils literal">ShippingAddress</tt> corresponds to any delivery address linked to the authenticated partner.
A partner can have between 0 and n <tt class="docutils literal">ShippingAddress</tt>.</p>
<dt>DeliveryAddress</dt>
<dd><p class="first">In the context of shopinvader, a <tt class="docutils literal">DeliveryAddress</tt> corresponds to any delivery address linked to the authenticated partner.
A partner can have between 0 and n <tt class="docutils literal">DeliveryAddress</tt>.</p>
<p>It can be created using:</p>
<pre class="code python literal-block">
<span class="k">def</span> <span class="nf">_create_shopinvader_shipping_address</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vals</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">&quot;ResPartner&quot;</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">_create_shopinvader_delivery_address</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vals</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">&quot;ResPartner&quot;</span><span class="p">:</span>
</pre>
<p>It can be updated using:</p>
<pre class="code python literal-block">
<span class="k">def</span> <span class="nf">_update_shopinvader_shipping_address</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vals</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">address_id</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">&quot;ResPartner&quot;</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">_update_shopinvader_delivery_address</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vals</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">address_id</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">&quot;ResPartner&quot;</span><span class="p">:</span>
</pre>
<p class="last"><em>Remark: it cannot be modified if it has already been used on a confirmed sale order.</em></p>
</dd>
Expand Down
2 changes: 1 addition & 1 deletion shopinvader_api_address/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Shopinvader Address Api
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3665e5551351ded5e0f9e6f9242d6625353997d627dac9a04f601b86865c72d2
!! source digest: sha256:83dafcf0bf274f0d5de75caaa140a3dca45d175c321fecc55e5546fdbb3f6805
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
Loading
Loading