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

[18.0][MIG]: Migration partner_invoicing_mode_at_shipping to 18.0 #1835

Open
wants to merge 10 commits into
base: 18.0
Choose a base branch
from
94 changes: 94 additions & 0 deletions partner_invoicing_mode_at_shipping/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
==================================
Partner Invoicing Mode At Shipping
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:56633cb4b17fae8ac33e95dd4ae02ad4ef513adf71cf972a8db705a28fdec624
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/18.0/partner_invoicing_mode_at_shipping
:alt: OCA/account-invoicing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoicing-18-0/account-invoicing-18-0-partner_invoicing_mode_at_shipping
: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/account-invoicing&target_branch=18.0
:alt: Try me on Runboat

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

This module allows to select a At shipping invoicing mode for a
customer. It is based on partner_invoicing_mode. When this mode is
selected the customer will be invoiced automatically on delivery of the
goods.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/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/account-invoicing/issues/new?body=module:%20partner_invoicing_mode_at_shipping%0Aversion:%2018.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

Contributors
------------

- `Camptocamp <https://www.camptocamp.com>`__:

- Thierry Ducrest <thierry.ducrest@camptocamp.com>

- Phuc (Tran Thanh) <phuc@trobz.com>

- Nils Coenen <nils.coenen@nico-solutions.de>

- Chau Le <chaulb@trobz.com>

Other credits
-------------

The development of this module has been financially supported by:

- Camptocamp

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/account-invoicing <https://github.com/OCA/account-invoicing/tree/18.0/partner_invoicing_mode_at_shipping>`_ 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 partner_invoicing_mode_at_shipping/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions partner_invoicing_mode_at_shipping/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Partner Invoicing Mode At Shipping",
"version": "18.0.1.0.0",
"summary": "Create invoices automatically when goods are shipped.",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
"license": "AGPL-3",
"category": "Accounting & Finance",
"data": [
"data/queue_job_data.xml",
],
"depends": ["account", "partner_invoicing_mode", "queue_job", "stock"],
}
15 changes: 15 additions & 0 deletions partner_invoicing_mode_at_shipping/data/queue_job_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Queue Job Channel -->
<record id="invoice_at_shipping" model="queue.job.channel">
<field name="name">invoice_at_shipping</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>

<!-- Job Functions -->
<record id="job_function_invoicing_at_shipping" model="queue.job.function">
<field name="model_id" ref="stock.model_stock_picking" />
<field name="method">_invoicing_at_shipping</field>
<field name="channel_id" ref="invoice_at_shipping" />
</record>
</odoo>
50 changes: 50 additions & 0 deletions partner_invoicing_mode_at_shipping/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_invoicing_mode_at_shipping
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-07-29 10:09+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model.fields.selection,name:partner_invoicing_mode_at_shipping.selection__res_partner__invoicing_mode__at_shipping
msgid "At Shipping"
msgstr "En envío"

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model.fields,field_description:partner_invoicing_mode_at_shipping.field_res_partner__invoicing_mode
#: model:ir.model.fields,field_description:partner_invoicing_mode_at_shipping.field_res_users__invoicing_mode
msgid "Invoicing Mode"
msgstr "Modo de facturación"

#. module: partner_invoicing_mode_at_shipping
#. odoo-python
#: code:addons/partner_invoicing_mode_at_shipping/models/stock_picking.py:0
#, python-format
msgid "Nothing to invoice."
msgstr "Nada para Facturar."

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de existencias"

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_stock_picking
msgid "Transfer"
msgstr "Transferencia"
50 changes: 50 additions & 0 deletions partner_invoicing_mode_at_shipping/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_invoicing_mode_at_shipping
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-02-27 12:11+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model.fields.selection,name:partner_invoicing_mode_at_shipping.selection__res_partner__invoicing_mode__at_shipping
msgid "At Shipping"
msgstr "Alla spedizione"

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_res_partner
msgid "Contact"
msgstr "Contatto"

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model.fields,field_description:partner_invoicing_mode_at_shipping.field_res_partner__invoicing_mode
#: model:ir.model.fields,field_description:partner_invoicing_mode_at_shipping.field_res_users__invoicing_mode
msgid "Invoicing Mode"
msgstr "Modo fatturazione"

#. module: partner_invoicing_mode_at_shipping
#. odoo-python
#: code:addons/partner_invoicing_mode_at_shipping/models/stock_picking.py:0
#, python-format
msgid "Nothing to invoice."
msgstr "Nulla da fatturare."

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_stock_move
msgid "Stock Move"
msgstr "Movimento di magazzino"

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_stock_picking
msgid "Transfer"
msgstr "Trasferimento"
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_invoicing_mode_at_shipping
#
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: partner_invoicing_mode_at_shipping
#: model:ir.model.fields.selection,name:partner_invoicing_mode_at_shipping.selection__res_partner__invoicing_mode__at_shipping
msgid "At Shipping"
msgstr ""

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model.fields,field_description:partner_invoicing_mode_at_shipping.field_res_partner__invoicing_mode
#: model:ir.model.fields,field_description:partner_invoicing_mode_at_shipping.field_res_users__invoicing_mode
msgid "Invoicing Mode"
msgstr ""

#. module: partner_invoicing_mode_at_shipping
#. odoo-python
#: code:addons/partner_invoicing_mode_at_shipping/models/stock_picking.py:0
#, python-format
msgid "Nothing to invoice."
msgstr ""

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: partner_invoicing_mode_at_shipping
#: model:ir.model,name:partner_invoicing_mode_at_shipping.model_stock_picking
msgid "Transfer"
msgstr ""
3 changes: 3 additions & 0 deletions partner_invoicing_mode_at_shipping/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import res_partner
from . import stock_move
from . import stock_picking
13 changes: 13 additions & 0 deletions partner_invoicing_mode_at_shipping/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import fields, models


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

invoicing_mode = fields.Selection(
selection_add=[("at_shipping", "At Shipping")],
ondelete={"at_shipping": "set default"},
)
19 changes: 19 additions & 0 deletions partner_invoicing_mode_at_shipping/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import models


class StockMove(models.Model):
_inherit = "stock.move"

def _get_related_invoices(self):
"""Overridden from stock_account to return the customer invoices
related to this stock move.
"""
invoices = super()._get_related_invoices()
line_invoices = self.sale_line_id.order_id.invoice_ids.filtered(
lambda x: x.state == "posted"
)
invoices |= line_invoices
return invoices
46 changes: 46 additions & 0 deletions partner_invoicing_mode_at_shipping/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import _, api, models


class StockPicking(models.Model):
_inherit = "stock.picking"

def _action_done(self):
res = super()._action_done()
for picking in self:
if picking._invoice_at_shipping():
picking._invoicing_at_shipping()
return res

def _invoice_at_shipping(self):
"""Check if picking must be invoiced at shipping."""
self.ensure_one()
return (
self.picking_type_code == "outgoing"
and self.sale_id.partner_invoice_id.invoicing_mode == "at_shipping"
)

@api.model
def _invoicing_at_shipping(self):
self.ensure_one()
sales = self._get_sales_order_to_invoice()
# Split invoice creation on partner sales grouping on invoice settings
sales_one_invoice_per_order = sales.filtered(
"partner_invoice_id.one_invoice_per_order"
)
invoices = self.env["account.move"]
if sales_one_invoice_per_order:
invoices |= sales_one_invoice_per_order._create_invoices(grouped=True)
sales_many_invoice_per_order = sales - sales_one_invoice_per_order
if sales_many_invoice_per_order:
invoices |= sales_many_invoice_per_order._create_invoices(grouped=False)
for invoice in invoices:
invoice._validate_invoice()
return invoices or _("Nothing to invoice.")

def _get_sales_order_to_invoice(self):
return self.move_ids.sale_line_id.order_id.filtered(
lambda r: r._get_invoiceable_lines()
)
3 changes: 3 additions & 0 deletions partner_invoicing_mode_at_shipping/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- [Camptocamp](https://www.camptocamp.com):

> - Thierry Ducrest \<<thierry.ducrest@camptocamp.com>\>

- Phuc (Tran Thanh) \<<phuc@trobz.com>\>
- Nils Coenen \<<nils.coenen@nico-solutions.de>\>
- Chau Le \<<chaulb@trobz.com>\>
3 changes: 3 additions & 0 deletions partner_invoicing_mode_at_shipping/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development of this module has been financially supported by:

- Camptocamp
4 changes: 4 additions & 0 deletions partner_invoicing_mode_at_shipping/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module allows to select a At shipping invoicing mode for a
customer. It is based on partner_invoicing_mode. When this mode is
selected the customer will be invoiced automatically on delivery of the
goods.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading