[MIG] account_purchase_stock_report_non_billed: Migration to 15.0

pull/1184/head
Stefan 2023-01-31 12:33:40 +01:00 committed by Pedro M. Baeza
parent 15fc4ce3ae
commit fbf61bf1ee
8 changed files with 116 additions and 99 deletions

View File

@ -2,10 +2,13 @@
Account Purchase Stock Report Non Billed Account Purchase Stock Report Non Billed
======================================== ========================================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c37c8ec835eb51f05c6963474a48e4ed84721ed38cc44bb0113dec12564bb2b4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status :target: https://odoo-community.org/page/development-status
@ -14,14 +17,14 @@ Account Purchase Stock Report Non Billed
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-reporting/tree/13.0/account_purchase_stock_report_non_billed :target: https://github.com/OCA/account-financial-reporting/tree/15.0/account_purchase_stock_report_non_billed
:alt: OCA/account-financial-reporting :alt: OCA/account-financial-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-account_purchase_stock_report_non_billed :target: https://translation.odoo-community.org/projects/account-financial-reporting-15-0/account-financial-reporting-15-0-account_purchase_stock_report_non_billed
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/91/13.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-reporting&target_branch=15.0
:alt: Try me on Runbot :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -48,8 +51,8 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_purchase_stock_report_non_billed%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_purchase_stock_report_non_billed%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. Do not contact contributors directly about support or help with technical issues.
@ -68,6 +71,7 @@ Contributors
* Carlos Roca * Carlos Roca
* Pedro M. Baeza * Pedro M. Baeza
* Stefan Ungureanu
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -90,6 +94,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-CarlosRoca13| |maintainer-CarlosRoca13|
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/13.0/account_purchase_stock_report_non_billed>`_ project on GitHub. This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/15.0/account_purchase_stock_report_non_billed>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Account Purchase Stock Report Non Billed", "name": "Account Purchase Stock Report Non Billed",
"version": "13.0.1.1.0", "version": "15.0.1.0.0",
"license": "AGPL-3", "license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)", "author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-reporting", "website": "https://github.com/OCA/account-financial-reporting",

View File

@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 13.0\n" "Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"

View File

@ -8,14 +8,14 @@ msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-30 06:00+0000\n" "POT-Creation-Date: 2022-08-30 06:00+0000\n"
"PO-Revision-Date: 2022-08-30 08:15+0200\n" "PO-Revision-Date: 2022-08-30 08:15+0200\n"
"Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.3\n" "X-Generator: Poedit 2.3\n"
"Last-Translator: \n"
"Language: es\n"
#. module: account_purchase_stock_report_non_billed #. module: account_purchase_stock_report_non_billed
#: model:ir.model,name:account_purchase_stock_report_non_billed.model_stock_move #: model:ir.model,name:account_purchase_stock_report_non_billed.model_stock_move
@ -25,4 +25,6 @@ msgstr "Movimiento de stock"
#. module: account_purchase_stock_report_non_billed #. module: account_purchase_stock_report_non_billed
#: model:ir.model,name:account_purchase_stock_report_non_billed.model_account_sale_stock_report_non_billed_wiz #: model:ir.model,name:account_purchase_stock_report_non_billed.model_account_sale_stock_report_non_billed_wiz
msgid "Wizard to open stock moves that have not been invoiced at that time" msgid "Wizard to open stock moves that have not been invoiced at that time"
msgstr "Asistente para abrir movimientos de stock que no han sido facturados a una fecha dada." msgstr ""
"Asistente para abrir movimientos de stock que no han sido facturados a una "
"fecha dada."

View File

@ -13,7 +13,7 @@ class StockMove(models.Model):
if move.purchase_line_id: if move.purchase_line_id:
move.currency_id = move.purchase_line_id.currency_id move.currency_id = move.purchase_line_id.currency_id
else: else:
super(StockMove, move)._compute_currency_id() return super(StockMove, move)._compute_currency_id()
def get_quantity_invoiced(self, invoice_lines): def get_quantity_invoiced(self, invoice_lines):
if self.purchase_line_id: if self.purchase_line_id:
@ -23,8 +23,8 @@ class StockMove(models.Model):
sum( sum(
invoice_lines.mapped( invoice_lines.mapped(
lambda l: l.quantity lambda l: l.quantity
if (l.move_id.type == "in_invoice" and not self.to_refund) if (l.move_id.move_type == "in_invoice" and not self.to_refund)
or (l.move_id.type == "in_refund" and self.to_refund) or (l.move_id.move_type == "in_refund" and self.to_refund)
else -l.quantity else -l.quantity
) )
) )
@ -70,12 +70,12 @@ class StockMove(models.Model):
) )
self.price_not_invoiced = (qty_to_invoice - invoiced_qty) * price_unit self.price_not_invoiced = (qty_to_invoice - invoiced_qty) * price_unit
else: else:
super()._set_not_invoiced_values(qty_to_invoice, invoiced_qty) return super()._set_not_invoiced_values(qty_to_invoice, invoiced_qty)
@api.depends("purchase_line_id") @api.depends("purchase_line_id")
@api.depends_context("date_check_invoiced_moves") @api.depends_context("date_check_invoiced_moves")
def _compute_not_invoiced_values(self): def _compute_not_invoiced_values(self):
super()._compute_not_invoiced_values() return super()._compute_not_invoiced_values()
def _get_model_id_origin_document(self): def _get_model_id_origin_document(self):
if not self.purchase_line_id: if not self.purchase_line_id:

View File

@ -2,3 +2,4 @@
* Carlos Roca * Carlos Roca
* Pedro M. Baeza * Pedro M. Baeza
* Stefan Ungureanu

View File

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Account Purchase Stock Report Non Billed</title> <title>Account Purchase Stock Report Non Billed</title>
<style type="text/css"> <style type="text/css">
/* /*
:Author: David Goodger (goodger@python.org) :Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $ :Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain. :Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils. Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
*/ */
@ -366,25 +366,27 @@ ul.auto-toc {
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c37c8ec835eb51f05c6963474a48e4ed84721ed38cc44bb0113dec12564bb2b4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/account-financial-reporting/tree/13.0/account_purchase_stock_report_non_billed"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-account_purchase_stock_report_non_billed"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/91/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-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-financial-reporting/tree/15.0/account_purchase_stock_report_non_billed"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-reporting-15-0/account-financial-reporting-15-0-account_purchase_stock_report_non_billed"><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-financial-reporting&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>Module that extends account_sale_stock_report_non_billed to add the non billed stock <p>Module that extends account_sale_stock_report_non_billed to add the non billed stock
moves comming from purchase orders.</p> moves comming from purchase orders.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li> <li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li> <li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul> <li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li> <li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li> <li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li> <li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1> <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To use this module, you need to:</p> <p>To use this module, you need to:</p>
<ol class="arabic simple"> <ol class="arabic simple">
<li>Go to <cite>Invicing &gt; Reporting &gt; Non Billed Stock Moves</cite>.</li> <li>Go to <cite>Invicing &gt; Reporting &gt; Non Billed Stock Moves</cite>.</li>
@ -394,41 +396,42 @@ showed at the tree view.</li>
</ol> </ol>
</div> </div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1> <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 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-financial-reporting/issues/new?body=module:%20account_purchase_stock_report_non_billed%0Aversion:%2013.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-financial-reporting/issues/new?body=module:%20account_purchase_stock_report_non_billed%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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
<h1><a class="toc-backref" href="#id3">Credits</a></h1> <h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors"> <div class="section" id="authors">
<h2><a class="toc-backref" href="#id4">Authors</a></h2> <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Tecnativa</li> <li>Tecnativa</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2> <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple"> <ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul> <li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Carlos Roca</li> <li>Carlos Roca</li>
<li>Pedro M. Baeza</li> <li>Pedro M. Baeza</li>
<li>Stefan Ungureanu</li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2> <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <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" /></a> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/CarlosRoca13"><img alt="CarlosRoca13" src="https://github.com/CarlosRoca13.png?size=40px" /></a></p> <p><a class="reference external image-reference" href="https://github.com/CarlosRoca13"><img alt="CarlosRoca13" src="https://github.com/CarlosRoca13.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/13.0/account_purchase_stock_report_non_billed">OCA/account-financial-reporting</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/15.0/account_purchase_stock_report_non_billed">OCA/account-financial-reporting</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> <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>
</div> </div>

View File

@ -3,10 +3,11 @@
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from odoo import fields from odoo import fields
from odoo.tests import Form, common from odoo.tests import Form, common, tagged
class TestAccountPurchaseStockReportNonBilled(common.SavepointCase): @tagged("-at_install", "post_install")
class TestAccountPurchaseStockReportNonBilled(common.TransactionCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super().setUpClass() super().setUpClass()
@ -39,9 +40,9 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
def test_02_report_move_full_invoiced(self): def test_02_report_move_full_invoiced(self):
picking = self.get_picking_done_po() picking = self.get_picking_done_po()
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
invoice = inv_form.save() invoice.invoice_date = self.po.create_date
invoice.action_post() invoice.action_post()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create( wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()} {"date_check": fields.Date.today()}
@ -58,16 +59,16 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
picking.action_confirm() picking.action_confirm()
move_done = picking.move_lines[0] move_done = picking.move_lines[0]
move_done.quantity_done = 1.0 move_done.quantity_done = 1.0
picking.action_done() picking.button_validate()
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
inv = inv_form.save() invoice.invoice_date = self.po.create_date
inv.action_post() invoice.action_post()
# Done other moves to appear at report # Done other moves to appear at report
picking_ret = self.po.picking_ids.filtered(lambda p: p.state == "assigned") picking_ret = self.po.picking_ids.filtered(lambda p: p.state == "assigned")
picking_ret.action_confirm() picking_ret.action_confirm()
picking_ret.move_lines.quantity_done = 1.0 picking_ret.move_lines.quantity_done = 1.0
picking_ret.action_done() picking_ret.button_validate()
moves_not_done = picking_ret.move_lines moves_not_done = picking_ret.move_lines
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create( wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()} {"date_check": fields.Date.today()}
@ -87,9 +88,9 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
picking.move_lines.quantity_done = 1.0 picking.move_lines.quantity_done = 1.0
picking.button_validate() picking.button_validate()
# Create invoice # Create invoice
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
invoice = inv_form.save() invoice.invoice_date = self.po.create_date
invoice.action_post() invoice.action_post()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create( wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()} {"date_check": fields.Date.today()}
@ -102,7 +103,13 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
wiz_invoice_refund = ( wiz_invoice_refund = (
self.env["account.move.reversal"] self.env["account.move.reversal"]
.with_context(active_model="account.move", active_ids=invoice.ids) .with_context(active_model="account.move", active_ids=invoice.ids)
.create({"refund_method": "cancel", "reason": "test"}) .create(
{
"refund_method": "cancel",
"reason": "test",
"journal_id": invoice.journal_id.id,
}
)
) )
wiz_invoice_refund.reverse_moves() wiz_invoice_refund.reverse_moves()
action = wiz.open_at_date() action = wiz.open_at_date()
@ -110,10 +117,10 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
for move in picking.move_lines: for move in picking.move_lines:
self.assertIn(move.id, domain_ids) self.assertIn(move.id, domain_ids)
# Create invoice again # Create invoice again
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) new_invoice = self.env["account.move"].browse([(inv_action["res_id"])])
new_inv = inv_form.save() new_invoice.invoice_date = self.po.create_date
new_inv.action_post() new_invoice.action_post()
action = wiz.open_at_date() action = wiz.open_at_date()
domain_ids = action["domain"][0][2] domain_ids = action["domain"][0][2]
for move in picking.move_lines: for move in picking.move_lines:
@ -125,12 +132,11 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
picking = self.po.picking_ids[0] picking = self.po.picking_ids[0]
picking.action_confirm() picking.action_confirm()
picking.move_lines.quantity_done = 3.0 picking.move_lines.quantity_done = 3.0
picking.button_validate() res_dict = picking.button_validate()
move_lines = picking.move_lines move_lines = picking.move_lines
wiz = self.env["stock.backorder.confirmation"].create( self.env["stock.backorder.confirmation"].with_context(
{"pick_ids": [(4, picking.id)]} **res_dict["context"]
) ).process()
wiz.process()
picking = self.po.picking_ids.filtered(lambda p: p.state != "done") picking = self.po.picking_ids.filtered(lambda p: p.state != "done")
picking.action_confirm() picking.action_confirm()
picking.move_lines.quantity_done = 2.0 picking.move_lines.quantity_done = 2.0
@ -143,9 +149,9 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
domain_ids = action["domain"][0][2] domain_ids = action["domain"][0][2]
for move in move_lines: for move in move_lines:
self.assertIn(move.id, domain_ids) self.assertIn(move.id, domain_ids)
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
invoice = inv_form.save() invoice.invoice_date = self.po.create_date
invoice.action_post() invoice.action_post()
action = wiz.open_at_date() action = wiz.open_at_date()
domain_ids = action["domain"][0][2] domain_ids = action["domain"][0][2]
@ -158,15 +164,14 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
picking = self.po.picking_ids[0] picking = self.po.picking_ids[0]
picking.action_confirm() picking.action_confirm()
picking.move_lines.quantity_done = 3.0 picking.move_lines.quantity_done = 3.0
picking.button_validate() res_dict = picking.button_validate()
wiz = self.env["stock.backorder.confirmation"].create(
{"pick_ids": [(4, picking.id)]}
)
wiz.process()
move_lines = picking.move_lines move_lines = picking.move_lines
inv_action = self.po.action_view_invoice() self.env["stock.backorder.confirmation"].with_context(
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) **res_dict["context"]
invoice = inv_form.save() ).process()
inv_action = self.po.action_create_invoice()
invoice = self.env["account.move"].browse([(inv_action["res_id"])])
invoice.invoice_date = self.po.create_date
invoice.action_post() invoice.action_post()
picking = self.po.picking_ids.filtered(lambda p: p.state != "done") picking = self.po.picking_ids.filtered(lambda p: p.state != "done")
picking.action_confirm() picking.action_confirm()
@ -181,9 +186,9 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
self.assertNotIn(move.id, domain_ids) self.assertNotIn(move.id, domain_ids)
for move in picking.move_lines: for move in picking.move_lines:
self.assertIn(move.id, domain_ids) self.assertIn(move.id, domain_ids)
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
invoice = inv_form.save() invoice.invoice_date = self.po.create_date
invoice.action_post() invoice.action_post()
action = wiz.open_at_date() action = wiz.open_at_date()
domain_ids = action["domain"][0][2] domain_ids = action["domain"][0][2]
@ -199,9 +204,9 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
picking.move_lines.quantity_done = 1.0 picking.move_lines.quantity_done = 1.0
picking.button_validate() picking.button_validate()
# Create invoice # Create invoice
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
invoice = inv_form.save() invoice.invoice_date = self.po.create_date
invoice.action_post() invoice.action_post()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create( wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()} {"date_check": fields.Date.today()}
@ -221,7 +226,7 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
return_id = wiz_return.create_returns()["res_id"] return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id) picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 1}) picking_return.move_line_ids.write({"qty_done": 1})
picking_return.action_done() picking_return.button_validate()
for move in picking_return.move_lines: for move in picking_return.move_lines:
self.assertNotIn(move.id, domain_ids) self.assertNotIn(move.id, domain_ids)
@ -242,7 +247,7 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
return_id = wiz_return.create_returns()["res_id"] return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id) picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 1}) picking_return.move_line_ids.write({"qty_done": 1})
picking_return.action_done() picking_return.button_validate()
wiz_return_return_form = Form( wiz_return_return_form = Form(
self.env["stock.return.picking"].with_context( self.env["stock.return.picking"].with_context(
active_model="stock.picking", active_id=picking_return.id active_model="stock.picking", active_id=picking_return.id
@ -252,10 +257,11 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
return_return_id = wiz_return_return.create_returns()["res_id"] return_return_id = wiz_return_return.create_returns()["res_id"]
picking_return_return = self.env["stock.picking"].browse(return_return_id) picking_return_return = self.env["stock.picking"].browse(return_return_id)
picking_return_return.move_line_ids.write({"qty_done": 1}) picking_return_return.move_line_ids.write({"qty_done": 1})
picking_return_return.action_done() picking_return_return.button_validate()
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
inv_form.save() invoice.invoice_date = self.po.create_date
invoice.action_post()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create( wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()} {"date_check": fields.Date.today()}
) )
@ -285,7 +291,7 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
return_id = wiz_return.create_returns()["res_id"] return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id) picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 1}) picking_return.move_line_ids.write({"qty_done": 1})
picking_return.action_done() picking_return.button_validate()
wiz_return_return_form = Form( wiz_return_return_form = Form(
self.env["stock.return.picking"].with_context( self.env["stock.return.picking"].with_context(
active_model="stock.picking", active_id=picking_return.id active_model="stock.picking", active_id=picking_return.id
@ -295,7 +301,7 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
return_return_id = wiz_return_return.create_returns()["res_id"] return_return_id = wiz_return_return.create_returns()["res_id"]
picking_return_return = self.env["stock.picking"].browse(return_return_id) picking_return_return = self.env["stock.picking"].browse(return_return_id)
picking_return_return.move_line_ids.write({"qty_done": 1}) picking_return_return.move_line_ids.write({"qty_done": 1})
picking_return_return.action_done() picking_return_return.button_validate()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create( wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()} {"date_check": fields.Date.today()}
) )
@ -316,9 +322,10 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
picking.action_confirm() picking.action_confirm()
picking.move_lines.quantity_done = 1.0 picking.move_lines.quantity_done = 1.0
picking.button_validate() picking.button_validate()
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
inv_form.save() invoice.invoice_date = self.po.create_date
invoice.action_post()
wiz_return_form = Form( wiz_return_form = Form(
self.env["stock.return.picking"].with_context( self.env["stock.return.picking"].with_context(
active_model="stock.picking", active_id=picking.id, to_refund=False active_model="stock.picking", active_id=picking.id, to_refund=False
@ -328,7 +335,7 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
return_id = wiz_return.create_returns()["res_id"] return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id) picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 1}) picking_return.move_line_ids.write({"qty_done": 1})
picking_return.action_done() picking_return.button_validate()
wiz_return_return_form = Form( wiz_return_return_form = Form(
self.env["stock.return.picking"].with_context( self.env["stock.return.picking"].with_context(
active_model="stock.picking", active_model="stock.picking",
@ -340,7 +347,7 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
return_return_id = wiz_return_return.create_returns()["res_id"] return_return_id = wiz_return_return.create_returns()["res_id"]
picking_return_return = self.env["stock.picking"].browse(return_return_id) picking_return_return = self.env["stock.picking"].browse(return_return_id)
picking_return_return.move_line_ids.write({"qty_done": 1}) picking_return_return.move_line_ids.write({"qty_done": 1})
picking_return_return.action_done() picking_return_return.button_validate()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create( wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()} {"date_check": fields.Date.today()}
) )
@ -362,10 +369,10 @@ class TestAccountPurchaseStockReportNonBilled(common.SavepointCase):
picking.move_lines.quantity_done = 1.0 picking.move_lines.quantity_done = 1.0
picking.button_validate() picking.button_validate()
# Emulate prepaying invoice # Emulate prepaying invoice
inv_action = self.po.action_view_invoice() inv_action = self.po.action_create_invoice()
inv_form = Form(self.env["account.move"].with_context(**inv_action["context"])) invoice = self.env["account.move"].browse([(inv_action["res_id"])])
inv_form.date = fields.Date.today() - relativedelta(days=5) invoice.invoice_date = fields.Date.today() - relativedelta(days=5)
inv_form.save() invoice.action_post()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create( wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today(), "interval_restrict_invoices": True} {"date_check": fields.Date.today(), "interval_restrict_invoices": True}
) )