Skip to content

Commit

Permalink
[MIG] sale_stock_picking_invoicing: Migration 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mbcosta committed Oct 28, 2024
1 parent 711808f commit ac17b88
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 42 deletions.
15 changes: 10 additions & 5 deletions sale_stock_picking_invoicing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Sales Stock Picking Invocing
: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/sale_stock_picking_invoicing
:target: https://github.com/OCA/account-invoicing/tree/15.0/sale_stock_picking_invoicing
: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-sale_stock_picking_invoicing
:target: https://translation.odoo-community.org/projects/account-invoicing-15-0/account-invoicing-15-0-sale_stock_picking_invoicing
: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=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -78,6 +78,11 @@ Known issues / Roadmap
Changelog
=========

15.0.1.0.0 (2024-10-25)
~~~~~~~~~~~~~~~~~~~~~~~

* Migration to version 15.0 .

14.0.1.0.0 (2024-03-12)
~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -89,7 +94,7 @@ 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:%20sale_stock_picking_invoicing%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20sale_stock_picking_invoicing%0Aversion:%2015.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.

Expand Down Expand Up @@ -145,6 +150,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-mbcosta| |maintainer-renatonlima|

This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/14.0/sale_stock_picking_invoicing>`_ project on GitHub.
This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/15.0/sale_stock_picking_invoicing>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion sale_stock_picking_invoicing/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "AGPL-3",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"maintainers": ["mbcosta", "renatonlima"],
"depends": [
"sale_management",
Expand Down
1 change: 0 additions & 1 deletion sale_stock_picking_invoicing/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def _default_sale_invoicing_policy(self):
("sale_order", "Sale Order"),
("stock_picking", "Stock Picking"),
],
string="Sale Invoicing Policy",
help="If set to Sale Order, keep native Odoo behaviour for creation of"
" invoices from Sale Orders.\n"
"If set to Stock Picking, disallow creation of Invoices from Sale Orders"
Expand Down
5 changes: 5 additions & 0 deletions sale_stock_picking_invoicing/readme/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
15.0.1.0.0 (2024-10-25)
~~~~~~~~~~~~~~~~~~~~~~~

* Migration to version 15.0 .

14.0.1.0.0 (2024-03-12)
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
41 changes: 24 additions & 17 deletions sale_stock_picking_invoicing/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Sales Stock Picking Invocing</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c39cc35cdfeafd3361156b4cbcf173f922dfd8032d3fa193c0f1deec98237f12
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/OCA/account-invoicing/tree/14.0/sale_stock_picking_invoicing"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-14-0/account-invoicing-14-0-sale_stock_picking_invoicing"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/OCA/account-invoicing/tree/15.0/sale_stock_picking_invoicing"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-15-0/account-invoicing-15-0-sale_stock_picking_invoicing"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends Stock Picking Invoicing implementation to Sale, you can define the ‘Sale Invoicing Policy’:</p>
<ul class="simple">
<li>If set to Sale Order, keep native Odoo behaviour for creation of invoices from Sale Orders.</li>
Expand All @@ -384,15 +384,16 @@ <h1 class="title">Sales Stock Picking Invocing</h1>
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-4">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#changelog" id="toc-entry-5">Changelog</a><ul>
<li><a class="reference internal" href="#section-1" id="toc-entry-6">14.0.1.0.0 (2024-03-12)</a></li>
<li><a class="reference internal" href="#section-1" id="toc-entry-6">15.0.1.0.0 (2024-10-25)</a></li>
<li><a class="reference internal" href="#section-2" id="toc-entry-7">14.0.1.0.0 (2024-03-12)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-7">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-8">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-9">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-10">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-11">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-12">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-8">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-9">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-10">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-11">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-12">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-13">Maintainers</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -427,30 +428,36 @@ <h1><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h1>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#toc-entry-5">Changelog</a></h1>
<div class="section" id="section-1">
<h2><a class="toc-backref" href="#toc-entry-6">14.0.1.0.0 (2024-03-12)</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">15.0.1.0.0 (2024-10-25)</a></h2>
<ul class="simple">
<li>Migration to version 15.0 .</li>
</ul>
</div>
<div class="section" id="section-2">
<h2><a class="toc-backref" href="#toc-entry-7">14.0.1.0.0 (2024-03-12)</a></h2>
<ul class="simple">
<li>[ADD] Module sale_stock_picking_invoicing based in l10n_br_sale_stock <a class="reference external" href="https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_sale_stock">https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_sale_stock</a> .</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-7">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-8">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-invoicing/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-invoicing/issues/new?body=module:%20sale_stock_picking_invoicing%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-invoicing/issues/new?body=module:%20sale_stock_picking_invoicing%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-8">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-9">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-9">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-10">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-10">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-11">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://akretion.com">Akretion</a>:<ul>
<li>Renato Lima &lt;<a class="reference external" href="mailto:renato.lima&#64;akretion.com.br">renato.lima&#64;akretion.com.br</a>&gt;</li>
Expand All @@ -465,14 +472,14 @@ <h2><a class="toc-backref" href="#toc-entry-10">Contributors</a></h2>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-11">Other credits</a></h2>
<h2><a class="toc-backref" href="#toc-entry-12">Other credits</a></h2>
<p>The development of this module has been financially supported by:</p>
<ul class="simple">
<li>Aketion - www.akretion.com</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-12">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-13">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -482,7 +489,7 @@ <h2><a class="toc-backref" href="#toc-entry-12">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/mbcosta"><img alt="mbcosta" src="https://github.com/mbcosta.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/renatonlima"><img alt="renatonlima" src="https://github.com/renatonlima.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-invoicing/tree/14.0/sale_stock_picking_invoicing">OCA/account-invoicing</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-invoicing/tree/15.0/sale_stock_picking_invoicing">OCA/account-invoicing</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
18 changes: 6 additions & 12 deletions sale_stock_picking_invoicing/tests/test_sale_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# from stock_picking_invoicing
# https://github.com/OCA/account-invoicing/blob/16.0/
# stock_picking_invoicing/tests/common.py
from odoo.tests import Form, SavepointCase
from odoo.tests import Form, TransactionCase


class TestSaleStock(SavepointCase):
class TestSaleStock(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand All @@ -30,12 +30,10 @@ def setUpClass(cls):
company.sale_invoicing_policy = "stock_picking"

def _run_picking_onchanges(self, record):
record.onchange_picking_type()
record.onchange_partner_id()

def _run_line_onchanges(self, record):
record.onchange_product()
record.onchange_product_uom()
record._onchange_product_id()

def picking_move_state(self, picking):
self._run_picking_onchanges(picking)
Expand Down Expand Up @@ -203,15 +201,15 @@ def test_picking_sale_order_product_and_service(self):
}
payment = (
self.env["sale.advance.payment.inv"]
.with_context(context)
.with_context(**context)
.create(
{
"advance_payment_method": "delivered",
}
)
)
with self.assertRaises(exceptions.UserError):
payment.with_context(context).create_invoices()
payment.with_context(**context).create_invoices()

invoice = self.create_invoice_wizard(picking)
self.assertEqual(picking.invoice_state, "invoiced")
Expand Down Expand Up @@ -416,7 +414,7 @@ def test_down_payment(self):
# DownPayment
payment_wizard = (
self.env["sale.advance.payment.inv"]
.with_context(context)
.with_context(**context)
.create(
{
"advance_payment_method": "percentage",
Expand All @@ -442,10 +440,6 @@ def test_down_payment(self):
limit=1,
)
payment_register.journal_id = journal_cash
payment_method_manual_in = self.env.ref(
"account.account_payment_method_manual_in"
)
payment_register.payment_method_id = payment_method_manual_in
payment_register.amount = invoice_down_payment.amount_total
payment_register.save()._create_payments()

Expand Down
33 changes: 27 additions & 6 deletions sale_stock_picking_invoicing/wizards/stock_invoice_onshipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,39 @@ def _get_invoice_line_values(self, moves, invoice_values, invoice):

return values

def _get_pickings_with_sale(self, invoice_values):
pickings = self._load_pickings()

# Filter Picking with Sales
picking_in_invoice_values = self.env["stock.picking"]
for line in invoice_values.get("invoice_line_ids"):
if line[2]:
if len(line[2].get("move_line_ids")[0]) == 2:
# [(4, 233)],
move_line_id = line[2].get("move_line_ids")[0][1]
else:
# [(<Command.SET: 6>, 0, [51])]
move_line_id = line[2].get("move_line_ids")[0][2]

move_line = self.env["stock.move"].browse(move_line_id)
picking_in_invoice_values |= move_line.mapped("picking_id")

sale_pickings = pickings.filtered(
lambda pk: pk.sale_id
# Check Sales Ungrouped
and pk.id in picking_in_invoice_values.ids
)

return sale_pickings

def _create_invoice(self, invoice_values):
"""Override this method if you need to change any values of the
invoice and the lines before the invoice creation
:param invoice_values: dict with the invoice and its lines
:return: invoice
"""
pickings = self._load_pickings()
sale_pickings = pickings.filtered(
lambda pk: pk.sale_id
# Check Sales Ungrouped
and pk.id in invoice_values.get("picking_ids")[0][2]
)
sale_pickings = self._get_pickings_with_sale(invoice_values)

# Refund case don't included Section, Note or DownPayments
if not sale_pickings or self._get_invoice_type() == "out_refund":
return super()._create_invoice(invoice_values)
Expand Down
6 changes: 6 additions & 0 deletions setup/sale_stock_picking_invoicing/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit ac17b88

Please sign in to comment.