diff --git a/README.md b/README.md index 32575aaf4..74458e886 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ addon | version | maintainers | summary [l10n_ro_partner_unique](l10n_ro_partner_unique/) | 16.0.1.1.0 | [![feketemihai](https://github.com/feketemihai.png?size=30px)](https://github.com/feketemihai) | Creates a rule for vat and nrc unique for partners. [l10n_ro_stock](l10n_ro_stock/) | 16.0.0.1.0 | [![feketemihai](https://github.com/feketemihai.png?size=30px)](https://github.com/feketemihai) | Romania - Stock [l10n_ro_stock_account](l10n_ro_stock_account/) | 16.0.1.1.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) [![feketemihai](https://github.com/feketemihai.png?size=30px)](https://github.com/feketemihai) | Romania - Stock Accounting +[l10n_ro_stock_account_date](l10n_ro_stock_account_date/) | 16.0.1.1.0 | [![feketemihai](https://github.com/feketemihai.png?size=30px)](https://github.com/feketemihai) | Romania - Stock Accounting Date +[l10n_ro_stock_account_date_wizard](l10n_ro_stock_account_date_wizard/) | 16.0.1.1.0 | [![feketemihai](https://github.com/feketemihai.png?size=30px)](https://github.com/feketemihai) | Romania - Stock Accounting Date Wizard [l10n_ro_vat_on_payment](l10n_ro_vat_on_payment/) | 16.0.1.1.0 | [![feketemihai](https://github.com/feketemihai.png?size=30px)](https://github.com/feketemihai) | Romania - VAT on Payment [//]: # (end addons) diff --git a/l10n_ro_stock_account/i18n/ro.po b/l10n_ro_stock_account/i18n/ro.po index a67fa6ab5..17793590c 100644 --- a/l10n_ro_stock_account/i18n/ro.po +++ b/l10n_ro_stock_account/i18n/ro.po @@ -17,6 +17,7 @@ msgstr "" "Plural-Forms: \n" #. module: l10n_ro_stock_account +#. odoo-python #: code:addons/l10n_ro_stock_account/models/stock_landed_cost.py:0 #, python-format msgid " already out" @@ -43,6 +44,7 @@ msgid "Companies" msgstr "Companii" #. module: l10n_ro_stock_account +#. odoo-python #: code:addons/l10n_ro_stock_account/models/stock_landed_cost.py:0 #, python-format msgid "" @@ -71,6 +73,7 @@ msgid "Display Name" msgstr "Nume afișat" #. module: l10n_ro_stock_account +#. odoo-python #: code:addons/l10n_ro_stock_account/models/product_category.py:0 #, python-format msgid "" @@ -194,13 +197,14 @@ msgid "" msgstr "" #. module: l10n_ro_stock_account +#. odoo-python #: code:addons/l10n_ro_stock_account/models/stock_landed_cost.py:0 #, python-format msgid "Please configure Stock Expense Account for product: %s." msgstr "" #. module: l10n_ro_stock_account -#: model:ir.model,name:l10n_ro_stock_account.model_product_product +#: model:ir.model,name:l10n_ro_stock_account.model_product_template msgid "Product" msgstr "" @@ -215,9 +219,9 @@ msgid "Product Moves (Stock Move Line)" msgstr "" #. module: l10n_ro_stock_account -#: model:ir.model,name:l10n_ro_stock_account.model_product_template -msgid "Product Template" -msgstr "Șablon produs" +#: model:ir.model,name:l10n_ro_stock_account.model_product_product +msgid "Product Variant" +msgstr "" #. module: l10n_ro_stock_account #: model:ir.model.fields,field_description:l10n_ro_stock_account.field_l10n_ro_stock_valuation_layer_tracking__quantity @@ -425,12 +429,16 @@ msgid "Wizard model to reavaluate a stock inventory for a product" msgstr "" #. module: l10n_ro_stock_account +#. odoo-python #: code:addons/l10n_ro_stock_account/models/stock_move_line.py:0 #, python-format msgid "" "You cannot decrease the quantity of a move line. Please create a return." msgstr "" +#~ msgid "Product Template" +#~ msgstr "Șablon produs" + #, python-format #~ msgid "" #~ "For Romanian Stock Accounting the stock_input, stock_output and " diff --git a/l10n_ro_stock_account_date/README.rst b/l10n_ro_stock_account_date/README.rst new file mode 100644 index 000000000..4789817ba --- /dev/null +++ b/l10n_ro_stock_account_date/README.rst @@ -0,0 +1,98 @@ +=============================== +Romania - Stock Accounting Date +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png + :target: https://odoo-community.org/page/development-status + :alt: Mature +.. |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%2Fl10n--romania-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-romania/tree/16.0/l10n_ro_stock_account_date + :alt: OCA/l10n-romania +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-romania-16-0/l10n-romania-16-0-l10n_ro_stock_account_date + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/177/16.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to select "Accounting Date" for stock operations. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +To install this module, you need to: + +* clone the branch 16.0 of the repository https://github.com/OCA/l10n-romania +* add the path to this repository in your configuration (addons-path) +* update the module list +* search for "Romania - Stock Account Date" in your addons +* install the module + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* NextERP Romania + +Contributors +~~~~~~~~~~~~ + +* `NextERP Romania `_: + + * Fekete Mihai + * Alexandru Teodor + * Cojocaru Marcel + +Do not contact contributors directly about support or help with technical issues. + +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. + +.. |maintainer-feketemihai| image:: https://github.com/feketemihai.png?size=40px + :target: https://github.com/feketemihai + :alt: feketemihai + +Current `maintainer `__: + +|maintainer-feketemihai| + +This module is part of the `OCA/l10n-romania `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_ro_stock_account_date/__init__.py b/l10n_ro_stock_account_date/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_ro_stock_account_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_ro_stock_account_date/__manifest__.py b/l10n_ro_stock_account_date/__manifest__.py new file mode 100644 index 000000000..bd32a6181 --- /dev/null +++ b/l10n_ro_stock_account_date/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright (C) 2022 NextERP Romania +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Romania - Stock Accounting Date", + "version": "16.0.1.1.0", + "category": "Localization", + "summary": "Romania - Stock Accounting Date", + "author": "NextERP Romania," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-romania", + "depends": ["l10n_ro_stock_account"], + "license": "AGPL-3", + "data": [ + "views/stock_picking_views.xml", + "views/stock_valuation_layer_views.xml", + ], + "installable": True, + "development_status": "Mature", + "maintainers": ["feketemihai"], +} diff --git a/l10n_ro_stock_account_date/i18n/l10n_ro_stock_account_date.pot b/l10n_ro_stock_account_date/i18n/l10n_ro_stock_account_date.pot new file mode 100644 index 000000000..6ff8c8244 --- /dev/null +++ b/l10n_ro_stock_account_date/i18n/l10n_ro_stock_account_date.pot @@ -0,0 +1,98 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ro_stock_account_date +# +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: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_picking__l10n_ro_accounting_date +#: model_terms:ir.ui.view,arch_db:l10n_ro_stock_account_date.view_picking_internal_search +msgid "Accounting Date" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__create_uid +msgid "Created by" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__create_date +msgid "Created on" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,help:l10n_ro_stock_account_date.field_stock_picking__l10n_ro_accounting_date +msgid "" +"If this field is set, the svl and accounting entiries will have this date, " +"If not will have the today date as it should be" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_move__is_l10n_ro_record +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_move_line__is_l10n_ro_record +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_picking__is_l10n_ro_record +msgid "Is Romanian Record" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__l10n_ro_date_done +msgid "L10N Ro Date Done" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__write_date +msgid "Last Updated on" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_valuation_layer +msgid "Stock Valuation Layer" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,help:l10n_ro_stock_account_date.field_stock_valuation_layer__l10n_ro_date_done +msgid "" +"This is the date when this record was created. Original create_date is " +"writen at reception by module nexterp_stock_date" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_picking +msgid "Transfer" +msgstr "" + +#. module: l10n_ro_stock_account_date +#. odoo-python +#: code:addons/l10n_ro_stock_account_date/models/stock_picking.py:0 +#, python-format +msgid "You can not have a Accounting date=%s for picking bigger than today!" +msgstr "" diff --git a/l10n_ro_stock_account_date/i18n/ro.po b/l10n_ro_stock_account_date/i18n/ro.po new file mode 100644 index 000000000..3689a59e0 --- /dev/null +++ b/l10n_ro_stock_account_date/i18n/ro.po @@ -0,0 +1,102 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ro_stock_account_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-10-07 07:36+0000\n" +"Last-Translator: Fekete Mihai \n" +"Language-Team: none\n" +"Language: ro\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < " +"20)) ? 1 : 2;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_picking__l10n_ro_accounting_date +#: model_terms:ir.ui.view,arch_db:l10n_ro_stock_account_date.view_picking_internal_search +msgid "Accounting Date" +msgstr "Data Contabila" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__create_uid +msgid "Created by" +msgstr "Creeat de" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__create_date +msgid "Created on" +msgstr "Creat la" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,help:l10n_ro_stock_account_date.field_stock_picking__l10n_ro_accounting_date +msgid "" +"If this field is set, the svl and accounting entiries will have this date, " +"If not will have the today date as it should be" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_move__is_l10n_ro_record +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_move_line__is_l10n_ro_record +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_picking__is_l10n_ro_record +msgid "Is Romanian Record" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__l10n_ro_date_done +msgid "L10N Ro Date Done" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date.field_stock_valuation_layer__write_date +msgid "Last Updated on" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_valuation_layer +msgid "Stock Valuation Layer" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model.fields,help:l10n_ro_stock_account_date.field_stock_valuation_layer__l10n_ro_date_done +msgid "" +"This is the date when this record was created. Original create_date is " +"writen at reception by module nexterp_stock_date" +msgstr "" + +#. module: l10n_ro_stock_account_date +#: model:ir.model,name:l10n_ro_stock_account_date.model_stock_picking +msgid "Transfer" +msgstr "" + +#. module: l10n_ro_stock_account_date +#. odoo-python +#: code:addons/l10n_ro_stock_account_date/models/stock_picking.py:0 +#, python-format +msgid "You can not have a Accounting date=%s for picking bigger than today!" +msgstr "" diff --git a/l10n_ro_stock_account_date/models/__init__.py b/l10n_ro_stock_account_date/models/__init__.py new file mode 100644 index 000000000..a6b5e4a24 --- /dev/null +++ b/l10n_ro_stock_account_date/models/__init__.py @@ -0,0 +1,5 @@ +from . import stock_move +from . import stock_move_line +from . import stock_quant +from . import stock_picking +from . import stock_valuation_layer diff --git a/l10n_ro_stock_account_date/models/stock_move.py b/l10n_ro_stock_account_date/models/stock_move.py new file mode 100644 index 000000000..59473e17a --- /dev/null +++ b/l10n_ro_stock_account_date/models/stock_move.py @@ -0,0 +1,97 @@ +# Copyright (C) 2022 NextERP Romania SRL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class StockMove(models.Model): + _name = "stock.move" + _inherit = ["stock.move", "l10n.ro.mixin"] + + def l10n_ro_get_move_date(self): + self.ensure_one() + new_date = self._context.get("force_period_date") + if not new_date: + if self.picking_id: + if self.picking_id.l10n_ro_accounting_date: + new_date = self.picking_id.l10n_ro_accounting_date + elif self.is_inventory: + new_date = self.date + elif "raw_material_production_id" in self._fields: + if self.raw_material_production_id: + new_date = self.raw_material_production_id.date_planned_start + elif self.production_id: + new_date = self.production_id.date_planned_start + if not new_date: + new_date = fields.datetime.now() + return new_date + + def _action_done(self, cancel_backorder=False): + moves_todo = super()._action_done(cancel_backorder=cancel_backorder) + for move in moves_todo.filtered("is_l10n_ro_record"): + move.date = move.l10n_ro_get_move_date() + return moves_todo + + def _trigger_assign(self): + res = super()._trigger_assign() + for move in self.filtered("is_l10n_ro_record"): + move.date = move.l10n_ro_get_move_date() + return res + + def _get_price_unit(self): + # Update price unit for purchases in different currencies with the + # reception date. + if self.is_l10n_ro_record: + if ( + self.origin_returned_move_id + and self.origin_returned_move_id.sudo().stock_valuation_layer_ids + ): + # in acest caz trebuie sa se execute din l10n_ro_stock_account + return super()._get_price_unit() + + if self.picking_id.date and self.purchase_line_id: + po_line = self.purchase_line_id + order = po_line.order_id + price_unit = po_line.price_unit + if po_line.product_qty != 0.0: + price_unit = po_line.price_subtotal / po_line.product_qty + + if po_line.taxes_id: + price_unit = po_line.taxes_id.with_context(round=False).compute_all( + price_unit, + currency=order.currency_id, + quantity=1.0, + product=po_line.product_id, + partner=order.partner_id, + )["total_excluded"] + if po_line.product_uom.id != po_line.product_id.uom_id.id: + price_unit *= ( + po_line.product_uom.factor / po_line.product_id.uom_id.factor + ) + if order.currency_id != order.company_id.currency_id: + price_unit = order.currency_id._convert( + price_unit, + order.company_id.currency_id, + self.company_id, + self.picking_id.l10n_ro_accounting_date + or fields.datetime.now(), + round=False, + ) + self.write( + { + "price_unit": price_unit, + "date": self.picking_id.l10n_ro_accounting_date + or fields.datetime.now(), + } + ) + return price_unit + return super()._get_price_unit() + + def _account_entry_move(self, qty, description, svl_id, cost): + self.ensure_one() + if self.is_l10n_ro_record: + val_date = self.l10n_ro_get_move_date() + self = self.with_context(force_period_date=val_date) + return super(StockMove, self)._account_entry_move( + qty, description, svl_id, cost + ) diff --git a/l10n_ro_stock_account_date/models/stock_move_line.py b/l10n_ro_stock_account_date/models/stock_move_line.py new file mode 100644 index 000000000..456859182 --- /dev/null +++ b/l10n_ro_stock_account_date/models/stock_move_line.py @@ -0,0 +1,17 @@ +# Copyright (C) 2022 NextERP Romania SRL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class StockMoveLine(models.Model): + _name = "stock.move.line" + _inherit = ["stock.move.line", "l10n.ro.mixin"] + + def _action_done(self): + res = super()._action_done() + ro_recs = self.exists().filtered("is_l10n_ro_record") + for move_line in ro_recs: + if move_line.move_id: + move_line.date = move_line.move_id.l10n_ro_get_move_date() + return res diff --git a/l10n_ro_stock_account_date/models/stock_picking.py b/l10n_ro_stock_account_date/models/stock_picking.py new file mode 100644 index 000000000..c67ca298b --- /dev/null +++ b/l10n_ro_stock_account_date/models/stock_picking.py @@ -0,0 +1,38 @@ +# Copyright (C) 2022 NextERP Romania SRL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import _, fields, models +from odoo.exceptions import ValidationError + + +class StockPicking(models.Model): + _name = "stock.picking" + _inherit = ["stock.picking", "l10n.ro.mixin"] + + l10n_ro_accounting_date = fields.Datetime( + "Accounting Date", + copy=False, + help="If this field is set, the svl and accounting entiries will " + "have this date, If not will have the today date as it should be", + tracking=True, + ) + + def _action_done(self): + """Update date_done from accounting_date field""" + res = super()._action_done() + for picking in self.filtered("is_l10n_ro_record"): + if picking.l10n_ro_accounting_date: + if picking.l10n_ro_accounting_date.date() > fields.date.today(): + raise ValidationError( + _( + "You can not have a Accounting date=%s for picking " + "bigger than today!" + ) + % picking.l10n_ro_accounting_date.date() + ) + picking.write( + { + "date_done": picking.l10n_ro_accounting_date, + } + ) + return res diff --git a/l10n_ro_stock_account_date/models/stock_quant.py b/l10n_ro_stock_account_date/models/stock_quant.py new file mode 100644 index 000000000..bc918c5ba --- /dev/null +++ b/l10n_ro_stock_account_date/models/stock_quant.py @@ -0,0 +1,26 @@ +# Copyright (C) 2022 NextERP Romania SRL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + def _get_inventory_move_values(self, qty, location_id, location_dest_id, out=False): + # Inherit to set date as accounting_date from inventoried quant + self.ensure_one() + vals = super()._get_inventory_move_values( + qty, location_id, location_dest_id, out + ) + if self.accounting_date: + vals["date"] = self.accounting_date + return vals + + def _apply_inventory(self): + # If accounting date is set, set also inventory date + res = super()._apply_inventory() + for quant in self: + if quant.accounting_date: + quant.inventory_date = quant.accounting_date + return res diff --git a/l10n_ro_stock_account_date/models/stock_valuation_layer.py b/l10n_ro_stock_account_date/models/stock_valuation_layer.py new file mode 100644 index 000000000..1c8b63df1 --- /dev/null +++ b/l10n_ro_stock_account_date/models/stock_valuation_layer.py @@ -0,0 +1,56 @@ +# Copyright (C) 2022 NextERP Romania SRL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class StockValuationLayer(models.Model): + _inherit = "stock.valuation.layer" + _log_access = False + + create_date = fields.Datetime("Created on", index=True, readonly=True) + create_uid = fields.Many2one("res.users", "Created by", index=True, readonly=True) + write_date = fields.Datetime("Last Updated on", index=True, readonly=True) + write_uid = fields.Many2one( + "res.users", "Last Updated by", index=True, readonly=True + ) + l10n_ro_date_done = fields.Datetime( + readonly=True, + help="This is the date when this record was created. Original create_date is writen" + " at reception by module nexterp_stock_date", + ) + + @api.model_create_multi + def create(self, vals_list): + for values in vals_list: + val_date = fields.datetime.now() + values.update( + { + "create_uid": self._uid, + "create_date": val_date, + "write_uid": self._uid, + "write_date": val_date, + } + ) + if self.env["res.company"]._check_is_l10n_ro_record( + values.get("company_id") + ): + if values.get("stock_move_id"): + move = self.env["stock.move"].browse(values["stock_move_id"]) + val_date = move.l10n_ro_get_move_date() + values.update( + { + "create_date": val_date, + "write_date": val_date, + "l10n_ro_date_done": fields.datetime.now(), + } + ) + return super().create(vals_list) + + def write(self, vals): + if self.filtered("is_l10n_ro_record"): + if not vals.get("write_uid"): + vals["write_uid"] = self._uid + if not vals.get("write_date"): + vals["write_date"] = fields.datetime.now() + return super().write(vals) diff --git a/l10n_ro_stock_account_date/readme/CONTRIBUTORS.rst b/l10n_ro_stock_account_date/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f0dd53f10 --- /dev/null +++ b/l10n_ro_stock_account_date/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* `NextERP Romania `_: + + * Fekete Mihai + * Alexandru Teodor + * Cojocaru Marcel + +Do not contact contributors directly about support or help with technical issues. diff --git a/l10n_ro_stock_account_date/readme/DESCRIPTION.rst b/l10n_ro_stock_account_date/readme/DESCRIPTION.rst new file mode 100644 index 000000000..031e25244 --- /dev/null +++ b/l10n_ro_stock_account_date/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows you to select "Accounting Date" for stock operations. diff --git a/l10n_ro_stock_account_date/readme/INSTALL.rst b/l10n_ro_stock_account_date/readme/INSTALL.rst new file mode 100644 index 000000000..f19c9d61b --- /dev/null +++ b/l10n_ro_stock_account_date/readme/INSTALL.rst @@ -0,0 +1,7 @@ +To install this module, you need to: + +* clone the branch 16.0 of the repository https://github.com/OCA/l10n-romania +* add the path to this repository in your configuration (addons-path) +* update the module list +* search for "Romania - Stock Account Date" in your addons +* install the module diff --git a/l10n_ro_stock_account_date/static/description/icon.png b/l10n_ro_stock_account_date/static/description/icon.png new file mode 100644 index 000000000..7ba9c1019 Binary files /dev/null and b/l10n_ro_stock_account_date/static/description/icon.png differ diff --git a/l10n_ro_stock_account_date/static/description/index.html b/l10n_ro_stock_account_date/static/description/index.html new file mode 100644 index 000000000..1cf9739ae --- /dev/null +++ b/l10n_ro_stock_account_date/static/description/index.html @@ -0,0 +1,439 @@ + + + + + + +Romania - Stock Accounting Date + + + +
+

Romania - Stock Accounting Date

+ + +

Mature License: AGPL-3 OCA/l10n-romania Translate me on Weblate Try me on Runbot

+

This module allows you to select “Accounting Date” for stock operations.

+

Table of contents

+ +
+

Installation

+

To install this module, you need to:

+
    +
  • clone the branch 16.0 of the repository https://github.com/OCA/l10n-romania
  • +
  • add the path to this repository in your configuration (addons-path)
  • +
  • update the module list
  • +
  • search for “Romania - Stock Account Date” in your addons
  • +
  • install the module
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • NextERP Romania
  • +
+
+
+

Contributors

+ +

Do not contact contributors directly about support or help with technical issues.

+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

feketemihai

+

This module is part of the OCA/l10n-romania project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_ro_stock_account_date/static/src/css/report.css b/l10n_ro_stock_account_date/static/src/css/report.css new file mode 100644 index 000000000..c37ada778 --- /dev/null +++ b/l10n_ro_stock_account_date/static/src/css/report.css @@ -0,0 +1,70 @@ +.act_as_table { + display: table; + background-color: white; +} +.act_as_row { + display: table-row; + page-break-inside: avoid; +} +.act_as_cell { + display: table-cell; + page-break-inside: avoid; +} +.act_as_thead { + display: table-header-group; +} +.act_as_row.labels { + background-color: #f0f0f0; +} +.data_table { + width: 100%; + border-left: 0px; + border-right: 0px; + text-align: center; + font-size: 10px; + padding-right: 3px; + padding-left: 3px; + padding-top: 2px; + padding-bottom: 2px; + border-collapse: collapse; +} +.data_table .act_as_cell { + border: 1px solid lightGrey; + text-align: center; +} + +.data_table .act_as_cell { + word-wrap: break-word; +} +.data_table .act_as_row.labels { + font-weight: bold; +} +.act_as_cell.left { + text-align: left; + padding: 5px 7px; +} +.act_as_cell.right { + text-align: right; + padding: 5px 7px; +} +.act_as_cell.sold { + font-style: italic; + font-weight: bold; +} + +.custom_footer { + font-size: 7px !important; +} +.button_row { + padding-bottom: 10px; +} +.o_stock_sheet_reports_page { + padding-top: 10px; + width: 90%; + margin-right: auto; + margin-left: auto; + font-family: Helvetica, Arial, serif; +} +.act_as_caption { + display: run-in; +} diff --git a/l10n_ro_stock_account_date/tests/__init__.py b/l10n_ro_stock_account_date/tests/__init__.py new file mode 100644 index 000000000..66210a1c2 --- /dev/null +++ b/l10n_ro_stock_account_date/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_accounting_date diff --git a/l10n_ro_stock_account_date/tests/test_stock_accounting_date.py b/l10n_ro_stock_account_date/tests/test_stock_accounting_date.py new file mode 100644 index 000000000..00778797b --- /dev/null +++ b/l10n_ro_stock_account_date/tests/test_stock_accounting_date.py @@ -0,0 +1,72 @@ +# Copyright (C) 2020 Terrabit +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +import logging +from datetime import timedelta + +from odoo import fields +from odoo.tests import tagged + +from odoo.addons.l10n_ro_stock_account.tests.common import TestStockCommon + +_logger = logging.getLogger(__name__) + + +@tagged("post_install", "-at_install") +class TestStockAccountDate(TestStockCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + + def test_inventory(self): + self.make_purchase() + acc_date = fields.Date.today() - timedelta(days=1) + inventory_obj = self.env["stock.quant"].with_context(inventory_mode=True) + inventory = inventory_obj.create( + { + "location_id": self.location_warehouse.id, + "product_id": self.product_1.id, + "inventory_quantity": self.qty_po_p1 + 10, + } + ) + inventory.accounting_date = acc_date + inventory._apply_inventory() + stock_move = self.env["stock.move"].search( + [ + ( + "location_id", + "=", + inventory.product_id.with_company( + inventory.company_id + ).property_stock_inventory.id, + ) + ] + ) + self.assertEqual(stock_move.date.date(), acc_date) + self.assertEqual(stock_move.move_line_ids.date.date(), acc_date) + self.assertEqual( + stock_move.stock_valuation_layer_ids.create_date.date(), acc_date + ) + self.assertTrue(stock_move.account_move_ids) + self.assertEqual(stock_move.account_move_ids.date, acc_date) + + def test_transfer(self): + self.set_stock(self.product_mp, 1000) + acc_date = fields.Date.today() - timedelta(days=1) + location_id = self.picking_type_transfer.default_location_src_id + location_dest_id = self.picking_type_transfer.default_location_dest_id.copy( + {"l10n_ro_property_stock_valuation_account_id": self.account_valuation.id} + ) + _logger.info("Start transfer") + self.transfer(location_id, location_dest_id, accounting_date=acc_date) + picking = self.picking + stock_move = picking.move_ids + _logger.info("Tranfer efectuat") + self.assertEqual(picking.l10n_ro_accounting_date.date(), acc_date) + self.assertEqual(stock_move.date.date(), acc_date) + self.assertEqual(stock_move.move_line_ids.date.date(), acc_date) + self.assertEqual( + stock_move.stock_valuation_layer_ids.mapped("create_date")[0].date(), + acc_date, + ) + self.assertEqual(stock_move.account_move_ids.date, acc_date) diff --git a/l10n_ro_stock_account_date/views/stock_picking_views.xml b/l10n_ro_stock_account_date/views/stock_picking_views.xml new file mode 100644 index 000000000..f084aa108 --- /dev/null +++ b/l10n_ro_stock_account_date/views/stock_picking_views.xml @@ -0,0 +1,60 @@ + + + stock.picking.tree + stock.picking + + + + + + + + + + + stock.picking.form + stock.picking + + + + + + + + + + stock.picking.internal.search + stock.picking + + + + + + + + + + diff --git a/l10n_ro_stock_account_date/views/stock_valuation_layer_views.xml b/l10n_ro_stock_account_date/views/stock_valuation_layer_views.xml new file mode 100644 index 000000000..db2ef0cd5 --- /dev/null +++ b/l10n_ro_stock_account_date/views/stock_valuation_layer_views.xml @@ -0,0 +1,16 @@ + + + stock.valuation.layer + + 290 + + + + + + + + diff --git a/l10n_ro_stock_account_date_wizard/README.rst b/l10n_ro_stock_account_date_wizard/README.rst new file mode 100644 index 000000000..2b56ba0b2 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/README.rst @@ -0,0 +1,98 @@ +====================================== +Romania - Stock Accounting Date Wizard +====================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png + :target: https://odoo-community.org/page/development-status + :alt: Mature +.. |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%2Fl10n--romania-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-romania/tree/16.0/l10n_ro_stock_account_date_wizard + :alt: OCA/l10n-romania +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-romania-16-0/l10n-romania-16-0-l10n_ro_stock_account_date_wizard + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/177/16.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to select "Accounting Date" for stock operations in the Stock Confirmation Wizards. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +To install this module, you need to: + +* clone the branch 16.0 of the repository https://github.com/OCA/l10n-romania +* add the path to this repository in your configuration (addons-path) +* update the module list +* search for "Romania - Stock Account Date Wizard" in your addons +* install the module + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* NextERP Romania + +Contributors +~~~~~~~~~~~~ + +* `NextERP Romania `_: + + * Fekete Mihai + * Alexandru Teodor + * Cojocaru Marcel + +Do not contact contributors directly about support or help with technical issues. + +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. + +.. |maintainer-feketemihai| image:: https://github.com/feketemihai.png?size=40px + :target: https://github.com/feketemihai + :alt: feketemihai + +Current `maintainer `__: + +|maintainer-feketemihai| + +This module is part of the `OCA/l10n-romania `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_ro_stock_account_date_wizard/__init__.py b/l10n_ro_stock_account_date_wizard/__init__.py new file mode 100644 index 000000000..40272379f --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/__init__.py @@ -0,0 +1 @@ +from . import wizard diff --git a/l10n_ro_stock_account_date_wizard/__manifest__.py b/l10n_ro_stock_account_date_wizard/__manifest__.py new file mode 100644 index 000000000..dc10ce525 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright (C) 2022 NextERP Romania +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Romania - Stock Accounting Date Wizard", + "version": "16.0.1.1.0", + "category": "Localization", + "summary": "Romania - Stock Accounting Date Wizard", + "author": "NextERP Romania," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-romania", + "depends": ["l10n_ro_stock_account_date"], + "license": "AGPL-3", + "data": [ + "wizard/stock_backorder_confirmation_views.xml", + "wizard/stock_immediate_transfer_views.xml", + ], + "installable": True, + "development_status": "Mature", + "maintainers": ["feketemihai"], +} diff --git a/l10n_ro_stock_account_date_wizard/i18n/l10n_ro_stock_account_date_wizard.pot b/l10n_ro_stock_account_date_wizard/i18n/l10n_ro_stock_account_date_wizard.pot new file mode 100644 index 000000000..6abd1e75e --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/i18n/l10n_ro_stock_account_date_wizard.pot @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ro_stock_account_date_wizard +# +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: l10n_ro_stock_account_date_wizard +#: model:ir.model,name:l10n_ro_stock_account_date_wizard.model_stock_backorder_confirmation +msgid "Backorder Confirmation" +msgstr "" + +#. module: l10n_ro_stock_account_date_wizard +#: model:ir.model.fields,help:l10n_ro_stock_account_date_wizard.field_stock_backorder_confirmation__l10n_ro_accounting_date +#: model:ir.model.fields,help:l10n_ro_stock_account_date_wizard.field_stock_immediate_transfer__l10n_ro_accounting_date +msgid "" +"If this field is set, the svl and accounting entiries will have this date, " +"If not will have the today date as it should be" +msgstr "" + +#. module: l10n_ro_stock_account_date_wizard +#: model:ir.model,name:l10n_ro_stock_account_date_wizard.model_stock_immediate_transfer +msgid "Immediate Transfer" +msgstr "" + +#. module: l10n_ro_stock_account_date_wizard +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date_wizard.field_stock_backorder_confirmation__is_l10n_ro_record +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date_wizard.field_stock_immediate_transfer__is_l10n_ro_record +msgid "Is Romanian Record" +msgstr "" + +#. module: l10n_ro_stock_account_date_wizard +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date_wizard.field_stock_backorder_confirmation__l10n_ro_accounting_date +#: model:ir.model.fields,field_description:l10n_ro_stock_account_date_wizard.field_stock_immediate_transfer__l10n_ro_accounting_date +msgid "L10N Ro Accounting Date" +msgstr "" + +#. module: l10n_ro_stock_account_date_wizard +#. odoo-python +#: code:addons/l10n_ro_stock_account_date_wizard/wizard/stock_backorder_confirmation.py:0 +#: code:addons/l10n_ro_stock_account_date_wizard/wizard/stock_backorder_confirmation.py:0 +#: code:addons/l10n_ro_stock_account_date_wizard/wizard/stock_immediate_transfer.py:0 +#, python-format +msgid "You can not have a Accounting date=%s for picking bigger than today!" +msgstr "" diff --git a/l10n_ro_stock_account_date_wizard/readme/CONTRIBUTORS.rst b/l10n_ro_stock_account_date_wizard/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f0dd53f10 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* `NextERP Romania `_: + + * Fekete Mihai + * Alexandru Teodor + * Cojocaru Marcel + +Do not contact contributors directly about support or help with technical issues. diff --git a/l10n_ro_stock_account_date_wizard/readme/DESCRIPTION.rst b/l10n_ro_stock_account_date_wizard/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6cb0a067f --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows you to select "Accounting Date" for stock operations in the Stock Confirmation Wizards. diff --git a/l10n_ro_stock_account_date_wizard/readme/INSTALL.rst b/l10n_ro_stock_account_date_wizard/readme/INSTALL.rst new file mode 100644 index 000000000..35475572f --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/readme/INSTALL.rst @@ -0,0 +1,7 @@ +To install this module, you need to: + +* clone the branch 16.0 of the repository https://github.com/OCA/l10n-romania +* add the path to this repository in your configuration (addons-path) +* update the module list +* search for "Romania - Stock Account Date Wizard" in your addons +* install the module diff --git a/l10n_ro_stock_account_date_wizard/static/description/icon.png b/l10n_ro_stock_account_date_wizard/static/description/icon.png new file mode 100644 index 000000000..7ba9c1019 Binary files /dev/null and b/l10n_ro_stock_account_date_wizard/static/description/icon.png differ diff --git a/l10n_ro_stock_account_date_wizard/static/description/index.html b/l10n_ro_stock_account_date_wizard/static/description/index.html new file mode 100644 index 000000000..f271e8210 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/static/description/index.html @@ -0,0 +1,439 @@ + + + + + + +Romania - Stock Accounting Date Wizard + + + +
+

Romania - Stock Accounting Date Wizard

+ + +

Mature License: AGPL-3 OCA/l10n-romania Translate me on Weblate Try me on Runbot

+

This module allows you to select “Accounting Date” for stock operations in the Stock Confirmation Wizards.

+

Table of contents

+ +
+

Installation

+

To install this module, you need to:

+
    +
  • clone the branch 16.0 of the repository https://github.com/OCA/l10n-romania
  • +
  • add the path to this repository in your configuration (addons-path)
  • +
  • update the module list
  • +
  • search for “Romania - Stock Account Date Wizard” in your addons
  • +
  • install the module
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • NextERP Romania
  • +
+
+
+

Contributors

+ +

Do not contact contributors directly about support or help with technical issues.

+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

feketemihai

+

This module is part of the OCA/l10n-romania project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_ro_stock_account_date_wizard/static/src/css/report.css b/l10n_ro_stock_account_date_wizard/static/src/css/report.css new file mode 100644 index 000000000..c37ada778 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/static/src/css/report.css @@ -0,0 +1,70 @@ +.act_as_table { + display: table; + background-color: white; +} +.act_as_row { + display: table-row; + page-break-inside: avoid; +} +.act_as_cell { + display: table-cell; + page-break-inside: avoid; +} +.act_as_thead { + display: table-header-group; +} +.act_as_row.labels { + background-color: #f0f0f0; +} +.data_table { + width: 100%; + border-left: 0px; + border-right: 0px; + text-align: center; + font-size: 10px; + padding-right: 3px; + padding-left: 3px; + padding-top: 2px; + padding-bottom: 2px; + border-collapse: collapse; +} +.data_table .act_as_cell { + border: 1px solid lightGrey; + text-align: center; +} + +.data_table .act_as_cell { + word-wrap: break-word; +} +.data_table .act_as_row.labels { + font-weight: bold; +} +.act_as_cell.left { + text-align: left; + padding: 5px 7px; +} +.act_as_cell.right { + text-align: right; + padding: 5px 7px; +} +.act_as_cell.sold { + font-style: italic; + font-weight: bold; +} + +.custom_footer { + font-size: 7px !important; +} +.button_row { + padding-bottom: 10px; +} +.o_stock_sheet_reports_page { + padding-top: 10px; + width: 90%; + margin-right: auto; + margin-left: auto; + font-family: Helvetica, Arial, serif; +} +.act_as_caption { + display: run-in; +} diff --git a/l10n_ro_stock_account_date_wizard/tests/__init__.py b/l10n_ro_stock_account_date_wizard/tests/__init__.py new file mode 100644 index 000000000..66210a1c2 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_accounting_date diff --git a/l10n_ro_stock_account_date_wizard/tests/test_stock_accounting_date.py b/l10n_ro_stock_account_date_wizard/tests/test_stock_accounting_date.py new file mode 100644 index 000000000..e227441e9 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/tests/test_stock_accounting_date.py @@ -0,0 +1,152 @@ +# Copyright (C) 2020 Terrabit +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +import logging +from datetime import timedelta + +from odoo import fields +from odoo.tests import Form, tagged + +from odoo.addons.l10n_ro_stock_account.tests.common import TestStockCommon + +_logger = logging.getLogger(__name__) + + +@tagged("post_install", "-at_install") +class TestStockReport(TestStockCommon): + def set_stock(self, product, qty): + inventory_obj = self.env["stock.quant"].with_context(inventory_mode=True) + inventory = inventory_obj.create( + { + "location_id": self.location_warehouse.id, + "product_id": product.id, + "inventory_quantity": qty, + } + ) + inventory._apply_inventory() + + def transfer(self, location, location_dest, product=None, accounting_date=False): + self.PickingObj = self.env["stock.picking"] + self.MoveObj = self.env["stock.move"] + self.MoveObj = self.env["stock.move"] + + if not product: + product = self.product_mp + + picking = self.PickingObj.create( + { + "picking_type_id": self.picking_type_transfer.id, + "location_id": location.id, + "location_dest_id": location_dest.id, + } + ) + self.MoveObj.create( + { + "name": product.name, + "product_id": product.id, + "product_uom_qty": 10, + "product_uom": product.uom_id.id, + "picking_id": picking.id, + "location_id": location.id, + "location_dest_id": location_dest.id, + } + ) + if accounting_date: + picking.l10n_ro_accounting_date = accounting_date + picking.action_confirm() + picking.action_assign() + for move_line in picking.move_ids: + if move_line.product_uom_qty > 0 and move_line.quantity_done == 0: + move_line.write({"quantity_done": move_line.product_uom_qty}) + return picking + + def test_transfer_backorder(self): + self.set_stock(self.product_mp, 1000) + acc_date = fields.Date.today() - timedelta(days=1) + location_id = self.picking_type_transfer.default_location_src_id + location_dest_id = self.picking_type_transfer.default_location_dest_id.copy( + {"l10n_ro_property_stock_valuation_account_id": self.account_valuation.id} + ) + _logger.info("Start transfer") + picking = self.transfer(location_id, location_dest_id) + picking.move_ids[0].move_line_ids[0].qty_done = 2 + action_data = picking.button_validate() + backorder_wizard = Form( + self.env["stock.backorder.confirmation"].with_context( + **action_data.get("context", {}) + ) + ).save() + backorder_wizard.l10n_ro_accounting_date = acc_date + backorder_wizard.process() + stock_move = picking.move_ids + _logger.info("Tranfer efectuat") + self.assertEqual(picking.l10n_ro_accounting_date.date(), acc_date) + self.assertEqual(stock_move.date.date(), acc_date) + self.assertEqual(stock_move.move_line_ids.date.date(), acc_date) + self.assertEqual( + stock_move.stock_valuation_layer_ids.mapped("create_date")[0].date(), + acc_date, + ) + self.assertEqual(stock_move.account_move_ids.date, acc_date) + + def test_transfer_cancel_backorder(self): + self.set_stock(self.product_mp, 1000) + acc_date = fields.Date.today() - timedelta(days=1) + location_id = self.picking_type_transfer.default_location_src_id + location_dest_id = self.picking_type_transfer.default_location_dest_id.copy( + {"l10n_ro_property_stock_valuation_account_id": self.account_valuation.id} + ) + _logger.info("Start transfer") + picking = self.transfer(location_id, location_dest_id) + picking.move_ids[0].move_line_ids[0].qty_done = 2 + action_data = picking.button_validate() + backorder_wizard = Form( + self.env["stock.backorder.confirmation"].with_context( + **action_data.get("context", {}) + ) + ).save() + backorder_wizard.l10n_ro_accounting_date = acc_date + backorder_wizard.process_cancel_backorder() + stock_move = picking.move_ids.filtered(lambda m: m.state == "done") + _logger.info("Tranfer efectuat") + self.assertEqual(picking.l10n_ro_accounting_date.date(), acc_date) + self.assertEqual(stock_move.date.date(), acc_date) + self.assertEqual(stock_move.move_line_ids.date.date(), acc_date) + self.assertEqual( + stock_move.stock_valuation_layer_ids.mapped("create_date")[0].date(), + acc_date, + ) + self.assertEqual(stock_move.account_move_ids.date, acc_date) + + def test_receipt(self): + picking_type_in = self.picking_type_in_warehouse + acc_date = fields.Date.today() - timedelta(days=1) + po = Form(self.env["purchase.order"]) + po.partner_id = self.vendor + po.picking_type_id = picking_type_in + + with po.order_line.new() as po_line: + po_line.product_id = self.product_1 + po_line.product_qty = self.qty_po_p1 + po_line.price_unit = self.price_p1 + + po = po.save() + po.button_confirm() + picking = po.picking_ids.filtered(lambda pick: pick.state != "done") + + wiz = picking.button_validate() + wiz = Form( + self.env["stock.immediate.transfer"].with_context(**wiz["context"]) + ).save() + wiz.l10n_ro_accounting_date = acc_date + wiz.process() + + stock_move = picking.move_ids + _logger.info("Tranfer efectuat") + self.assertEqual(picking.l10n_ro_accounting_date.date(), acc_date) + self.assertEqual(stock_move.date.date(), acc_date) + self.assertEqual(stock_move.move_line_ids.date.date(), acc_date) + self.assertEqual( + stock_move.stock_valuation_layer_ids.mapped("create_date")[0].date(), + acc_date, + ) diff --git a/l10n_ro_stock_account_date_wizard/wizard/__init__.py b/l10n_ro_stock_account_date_wizard/wizard/__init__.py new file mode 100644 index 000000000..7a5186a84 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/wizard/__init__.py @@ -0,0 +1,2 @@ +from . import stock_backorder_confirmation +from . import stock_immediate_transfer diff --git a/l10n_ro_stock_account_date_wizard/wizard/stock_backorder_confirmation.py b/l10n_ro_stock_account_date_wizard/wizard/stock_backorder_confirmation.py new file mode 100644 index 000000000..c42b23c2e --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/wizard/stock_backorder_confirmation.py @@ -0,0 +1,71 @@ +# Copyright (C) 2022 NextERP Romania SRL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class StockBackorderConfirmation(models.TransientModel): + _name = "stock.backorder.confirmation" + _inherit = ["stock.backorder.confirmation", "l10n.ro.mixin"] + + l10n_ro_accounting_date = fields.Datetime( + help="If this field is set, the svl and accounting entiries will " + "have this date, If not will have the today date as it should be", + default=fields.Datetime.now(), + ) + + @api.model + def default_get(self, fields): + res = super().default_get(fields) + if self.env["res.company"]._check_is_l10n_ro_record(self.env.company.id): + res["is_l10n_ro_record"] = True + if res.get("pick_ids"): + if ( + self.env["stock.picking"] + .browse(res["pick_ids"][0][2][0]) + .l10n_ro_accounting_date + ): + res["l10n_ro_accounting_date"] = ( + self.env["stock.picking"] + .browse(res["pick_ids"][0][2][0]) + .l10n_ro_accounting_date + ) + return res + + def process(self): + if self.is_l10n_ro_record: + if self.l10n_ro_accounting_date.date() > fields.date.today(): + raise ValidationError( + _( + "You can not have a Accounting date=%s for picking bigger than today!" + ) + % self.l10n_ro_accounting_date.date() + ) + self.pick_ids.write( + { + "l10n_ro_accounting_date": self.l10n_ro_accounting_date, + "date_done": self.l10n_ro_accounting_date, + } + ) + return super().process() + + def process_cancel_backorder(self): + if self.is_l10n_ro_record: + pickings_to_validate = self.env.context.get("button_validate_picking_ids") + if pickings_to_validate and self.l10n_ro_accounting_date: + if self.l10n_ro_accounting_date.date() > fields.date.today(): + raise ValidationError( + _( + "You can not have a Accounting date=%s for " + "picking bigger than today!" + ) + % self.l10n_ro_accounting_date.date() + ) + self.env["stock.picking"].browse(pickings_to_validate).write( + { + "l10n_ro_accounting_date": self.l10n_ro_accounting_date, + "date_done": self.l10n_ro_accounting_date, + } + ) + return super().process_cancel_backorder() diff --git a/l10n_ro_stock_account_date_wizard/wizard/stock_backorder_confirmation_views.xml b/l10n_ro_stock_account_date_wizard/wizard/stock_backorder_confirmation_views.xml new file mode 100644 index 000000000..971c779f2 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/wizard/stock_backorder_confirmation_views.xml @@ -0,0 +1,18 @@ + + + + stock.backorder.confirmation + + + + + + + + + + + diff --git a/l10n_ro_stock_account_date_wizard/wizard/stock_immediate_transfer.py b/l10n_ro_stock_account_date_wizard/wizard/stock_immediate_transfer.py new file mode 100644 index 000000000..12e5ebdb5 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/wizard/stock_immediate_transfer.py @@ -0,0 +1,53 @@ +# Copyright (C) 2022 NextERP Romania SRL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class StockImmediateTransfer(models.TransientModel): + _name = "stock.immediate.transfer" + _inherit = ["stock.immediate.transfer", "l10n.ro.mixin"] + + l10n_ro_accounting_date = fields.Datetime( + help="If this field is set, the svl and accounting entiries will " + "have this date, If not will have the today date as it should be", + default=fields.Datetime.now(), + ) + + @api.model + def default_get(self, fields): + res = super().default_get(fields) + if self.env["res.company"]._check_is_l10n_ro_record(self.env.company.id): + res["is_l10n_ro_record"] = True + if res.get("pick_ids"): + if ( + self.env["stock.picking"] + .browse(res["pick_ids"][0][2][0]) + .l10n_ro_accounting_date + ): + res["l10n_ro_accounting_date"] = ( + self.env["stock.picking"] + .browse(res["pick_ids"][0][2][0]) + .l10n_ro_accounting_date + ) + return res + + def process(self): + if self.is_l10n_ro_record: + if self.l10n_ro_accounting_date: + if self.l10n_ro_accounting_date.date() > fields.date.today(): + raise ValidationError( + _( + "You can not have a Accounting date=%s " + "for picking bigger than today!" + ) + % self.l10n_ro_accounting_date.date() + ) + self.pick_ids.write( + { + "l10n_ro_accounting_date": self.l10n_ro_accounting_date, + "date_done": self.l10n_ro_accounting_date, + } + ) + return super().process() diff --git a/l10n_ro_stock_account_date_wizard/wizard/stock_immediate_transfer_views.xml b/l10n_ro_stock_account_date_wizard/wizard/stock_immediate_transfer_views.xml new file mode 100644 index 000000000..4f39f9134 --- /dev/null +++ b/l10n_ro_stock_account_date_wizard/wizard/stock_immediate_transfer_views.xml @@ -0,0 +1,20 @@ + + + + stock.immediate.transfer + + + + + + + + + + + + + diff --git a/setup/_metapackage/VERSION.txt b/setup/_metapackage/VERSION.txt index 126ff1751..4fbdc9244 100644 --- a/setup/_metapackage/VERSION.txt +++ b/setup/_metapackage/VERSION.txt @@ -1 +1 @@ -16.0.20230530.0 \ No newline at end of file +16.0.20230530.2 \ No newline at end of file diff --git a/setup/_metapackage/setup.py b/setup/_metapackage/setup.py index cd48fcab0..057bcb9f7 100644 --- a/setup/_metapackage/setup.py +++ b/setup/_metapackage/setup.py @@ -18,6 +18,8 @@ 'odoo-addon-l10n_ro_partner_unique>=16.0dev,<16.1dev', 'odoo-addon-l10n_ro_stock>=16.0dev,<16.1dev', 'odoo-addon-l10n_ro_stock_account>=16.0dev,<16.1dev', + 'odoo-addon-l10n_ro_stock_account_date>=16.0dev,<16.1dev', + 'odoo-addon-l10n_ro_stock_account_date_wizard>=16.0dev,<16.1dev', 'odoo-addon-l10n_ro_vat_on_payment>=16.0dev,<16.1dev', ], classifiers=[ diff --git a/setup/l10n_ro_stock_account_date/odoo/addons/l10n_ro_stock_account_date b/setup/l10n_ro_stock_account_date/odoo/addons/l10n_ro_stock_account_date new file mode 120000 index 000000000..f3e1e38aa --- /dev/null +++ b/setup/l10n_ro_stock_account_date/odoo/addons/l10n_ro_stock_account_date @@ -0,0 +1 @@ +../../../../l10n_ro_stock_account_date \ No newline at end of file diff --git a/setup/l10n_ro_stock_account_date/setup.py b/setup/l10n_ro_stock_account_date/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/l10n_ro_stock_account_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/l10n_ro_stock_account_date_wizard/odoo/addons/l10n_ro_stock_account_date_wizard b/setup/l10n_ro_stock_account_date_wizard/odoo/addons/l10n_ro_stock_account_date_wizard new file mode 120000 index 000000000..034940542 --- /dev/null +++ b/setup/l10n_ro_stock_account_date_wizard/odoo/addons/l10n_ro_stock_account_date_wizard @@ -0,0 +1 @@ +../../../../l10n_ro_stock_account_date_wizard \ No newline at end of file diff --git a/setup/l10n_ro_stock_account_date_wizard/setup.py b/setup/l10n_ro_stock_account_date_wizard/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/l10n_ro_stock_account_date_wizard/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)