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

[MIG] account_invoice_mode_at_shipping: Migration to 15.0 #1101

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8605bd5
[13.0]]ADD] Add acconut_invoicing_mode
TDu Jul 7, 2020
59db698
Invoice sales based on moves
guewen Sep 9, 2020
7966788
Ensure _get_related_invoices include all the related invoices
guewen Sep 9, 2020
d75e435
[13.0][FIX] Add acconut_invoicing_mode
TDu Sep 22, 2020
002b58c
[13.0][FIX] account_invoicing_mode_at_shipping
TDu Apr 27, 2021
a2ae257
[13.0][FIX] account_invoicing_mode_at_shipping
TDu Apr 27, 2021
b626f09
[13.0][IMP] account_invoicing_mode_at_shipping
TDu Apr 27, 2021
edeeada
[IMP] account_invoice_mode: black, isort, prettier
phuctranfxvn Jan 10, 2021
c956fe8
[MIG] account_invoice_mode: Migration to 14.0
phuctranfxvn Jan 11, 2021
876a242
[UPD] Update account_invoice_mode_at_shipping.pot
oca-travis Aug 4, 2021
a26b73f
[UPD] README.rst
OCA-git-bot Aug 4, 2021
2ae04ed
[ADD] icon.png
OCA-git-bot Aug 4, 2021
e245148
account_invoice_mode_at_shipping 14.0.1.0.1
OCA-git-bot Aug 4, 2021
42d9bd2
[IMP] account_invoice_mode_*: Add ondelete attribute to 'invoicing_mo…
SilvioC2C Aug 5, 2021
b049756
account_invoice_mode_at_shipping 14.0.1.1.0
OCA-git-bot Aug 10, 2021
f0820ba
[UPD] README.rst
OCA-git-bot Nov 11, 2021
4471149
[UPD] README.rst
OCA-git-bot Nov 11, 2021
bb24f40
Added translation using Weblate (Catalan)
extrememicro Feb 3, 2022
45ac2e6
[IMP] account_invoice_mode_at_shipping: black, isort, prettier
BertVGroenendael Feb 14, 2022
ac88927
[MIG] account_invoice_mode_at_shipping: Migration to 15.0
BertVGroenendael Feb 14, 2022
05a866b
[ADD] dependency file for testing purpose
rven Feb 18, 2022
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
87 changes: 87 additions & 0 deletions account_invoice_mode_at_shipping/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
================================
Account Invoice Mode At Shipping
================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/14.0/account_invoice_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-14-0/account-invoicing-14-0-account_invoice_mode_at_shipping
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/95/14.0
:alt: Try me on Runbot

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

This module allows to select a `At shipping` invoicing mode for a customer.
It is based on `account_invoice_base_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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_mode_at_shipping%0Aversion:%2014.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 <[email protected]>

* Phuc (Tran Thanh) <[email protected]>

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/14.0/account_invoice_mode_at_shipping>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions account_invoice_mode_at_shipping/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import tests
15 changes: 15 additions & 0 deletions account_invoice_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": "Account Invoice Mode At Shipping",
"version": "15.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", "account_invoice_base_invoicing_mode", "queue_job", "stock"],
}
15 changes: 15 additions & 0 deletions account_invoice_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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_mode_at_shipping
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: account_invoice_mode_at_shipping
#: model:ir.model.fields.selection,name:account_invoice_mode_at_shipping.selection__res_partner__invoicing_mode__at_shipping
msgid "At Shipping"
msgstr ""

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

#. module: account_invoice_mode_at_shipping
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_res_partner__display_name
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_move__display_name
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_picking__display_name
msgid "Display Name"
msgstr ""

#. module: account_invoice_mode_at_shipping
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_res_partner__id
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_move__id
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_picking__id
msgid "ID"
msgstr ""

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

#. module: account_invoice_mode_at_shipping
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_res_partner____last_update
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_move____last_update
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_picking____last_update
msgid "Last Modified on"
msgstr ""

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

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

#. module: account_invoice_mode_at_shipping
#: model:ir.model,name:account_invoice_mode_at_shipping.model_stock_picking
msgid "Transfer"
msgstr ""
68 changes: 68 additions & 0 deletions account_invoice_mode_at_shipping/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_mode_at_shipping
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ca\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"

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

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

#. module: account_invoice_mode_at_shipping
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_res_partner__display_name
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_move__display_name
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_picking__display_name
msgid "Display Name"
msgstr ""

#. module: account_invoice_mode_at_shipping
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_res_partner__id
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_move__id
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_picking__id
msgid "ID"
msgstr ""

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

#. module: account_invoice_mode_at_shipping
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_res_partner____last_update
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_move____last_update
#: model:ir.model.fields,field_description:account_invoice_mode_at_shipping.field_stock_picking____last_update
msgid "Last Modified on"
msgstr ""

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

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

#. module: account_invoice_mode_at_shipping
#: model:ir.model,name:account_invoice_mode_at_shipping.model_stock_picking
msgid "Transfer"
msgstr ""
3 changes: 3 additions & 0 deletions account_invoice_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 account_invoice_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 account_invoice_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.mapped("sale_line_id.order_id.invoice_ids").filtered(
lambda x: x.state == "posted"
)
invoices |= line_invoices
return invoices
49 changes: 49 additions & 0 deletions account_invoice_mode_at_shipping/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import _, 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.with_delay()._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"
)

def _invoicing_at_shipping(self):
self.ensure_one()
sales = self.env["sale.order"].browse()
# Filter out non invoicable sales order
for sale in self._get_sales_order_to_invoice():
if sale._get_invoiceable_lines():
sales |= sale
# 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"].browse()
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.with_delay()._validate_invoice()
return invoices or _("Nothing to invoice.")

def _get_sales_order_to_invoice(self):
return self.mapped("move_lines.sale_line_id.order_id").filtered(
lambda r: r._get_invoiceable_lines()
)
5 changes: 5 additions & 0 deletions account_invoice_mode_at_shipping/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Camptocamp <https://www.camptocamp.com>`_:

* Thierry Ducrest <[email protected]>

* Phuc (Tran Thanh) <[email protected]>
3 changes: 3 additions & 0 deletions account_invoice_mode_at_shipping/readme/CREDITS.rst
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 account_invoice_mode_at_shipping/readme/DESCRIPTION.rst
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 `account_invoice_base_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