forked from OCA/l10n-brazil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by rvalyi
- Loading branch information
Showing
10 changed files
with
724 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
366 changes: 280 additions & 86 deletions
366
l10n_br_stock_account/demo/l10n_br_stock_account_demo.xml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="1"> | ||
|
||
<!-- Empresa Principal - Main Company --> | ||
<record id="stock_account_inventory_main" model="stock.inventory"> | ||
<field | ||
name="name" | ||
>Inventário Inicial l10n_br_stock_account - Empresa Principal</field> | ||
<field name="company_id" ref="base.main_company" /> | ||
</record> | ||
|
||
<record id="stock_account_inventory_main_line_1" model="stock.inventory.line"> | ||
<field name="product_id" ref="product.product_product_12" /> | ||
<field name="product_uom_id" ref="uom.product_uom_unit" /> | ||
<field name="inventory_id" ref="stock_account_inventory_main" /> | ||
<field name="product_qty">100.0</field> | ||
<field name="location_id" ref="stock.stock_location_stock" /> | ||
</record> | ||
|
||
<record id="stock_account_inventory_main_line_2" model="stock.inventory.line"> | ||
<field name="product_id" ref="product.product_product_16" /> | ||
<field name="product_uom_id" ref="uom.product_uom_unit" /> | ||
<field name="inventory_id" ref="stock_account_inventory_main" /> | ||
<field name="product_qty">100.0</field> | ||
<field name="location_id" ref="stock.stock_location_stock" /> | ||
</record> | ||
|
||
<function model="stock.inventory" name="action_start"> | ||
<function | ||
eval="[[('state','=','draft'),('id', '=', ref('stock_account_inventory_main'))]]" | ||
model="stock.inventory" | ||
name="search" | ||
/> | ||
</function> | ||
<function model="stock.inventory" name="action_validate"> | ||
<function | ||
eval="[[('state','=','confirm'),('id', '=', ref('stock_account_inventory_main'))]]" | ||
model="stock.inventory" | ||
name="search" | ||
/> | ||
</function> | ||
|
||
<!-- Simples Nacional --> | ||
<record id="stock_account_inventory_sn" model="stock.inventory"> | ||
<field | ||
name="name" | ||
>Inventário Inicial l10n_br_stock_account - Simples Nacional</field> | ||
<field name="company_id" ref="l10n_br_base.empresa_simples_nacional" /> | ||
</record> | ||
|
||
<record id="stock_account_inventory_sn_line_1" model="stock.inventory.line"> | ||
<field name="product_id" ref="product.product_product_12" /> | ||
<field name="product_uom_id" ref="uom.product_uom_unit" /> | ||
<field name="inventory_id" ref="stock_account_inventory_sn" /> | ||
<field name="product_qty">100.0</field> | ||
<field | ||
name="location_id" | ||
ref="l10n_br_stock.wh_empresa_simples_nacional_loc_stock_id" | ||
/> | ||
</record> | ||
<record id="stock_account_inventory_sn_line_2" model="stock.inventory.line"> | ||
<field name="product_id" ref="product.product_product_16" /> | ||
<field name="product_uom_id" ref="uom.product_uom_unit" /> | ||
<field name="inventory_id" ref="stock_account_inventory_sn" /> | ||
<field name="product_qty">100.0</field> | ||
<field | ||
name="location_id" | ||
ref="l10n_br_stock.wh_empresa_simples_nacional_loc_stock_id" | ||
/> | ||
</record> | ||
|
||
<function model="stock.inventory" name="action_start"> | ||
<function | ||
eval="[[('state','=','draft'),('id', '=', ref('stock_account_inventory_sn'))]]" | ||
model="stock.inventory" | ||
name="search" | ||
/> | ||
</function> | ||
<function model="stock.inventory" name="action_validate"> | ||
<function | ||
eval="[[('state','=','confirm'),('id', '=', ref('stock_account_inventory_sn'))]]" | ||
model="stock.inventory" | ||
name="search" | ||
/> | ||
</function> | ||
|
||
<!-- Lucro Presumido --> | ||
|
||
<record id="stock_account_inventory_lp" model="stock.inventory"> | ||
<field | ||
name="name" | ||
>Inventário Inicial l10n_br_stock_account - Lucro Presumido</field> | ||
<field name="company_id" ref="l10n_br_base.empresa_lucro_presumido" /> | ||
</record> | ||
|
||
<record id="stock_inventory_lp_line_1" model="stock.inventory.line"> | ||
<field name="product_id" ref="product.product_product_12" /> | ||
<field name="product_uom_id" ref="uom.product_uom_unit" /> | ||
<field name="inventory_id" ref="stock_account_inventory_lp" /> | ||
<field name="product_qty">100.0</field> | ||
<field | ||
name="location_id" | ||
ref="l10n_br_stock.wh_empresa_lucro_presumido_loc_stock_id" | ||
/> | ||
</record> | ||
<record id="stock_inventory_lp_line_2" model="stock.inventory.line"> | ||
<field name="product_id" ref="product.product_product_16" /> | ||
<field name="product_uom_id" ref="uom.product_uom_unit" /> | ||
<field name="inventory_id" ref="stock_account_inventory_lp" /> | ||
<field name="product_qty">100.0</field> | ||
<field | ||
name="location_id" | ||
ref="l10n_br_stock.wh_empresa_lucro_presumido_loc_stock_id" | ||
/> | ||
</record> | ||
|
||
<function model="stock.inventory" name="action_start"> | ||
<function | ||
eval="[[('state','=','draft'),('id', '=', ref('stock_account_inventory_lp'))]]" | ||
model="stock.inventory" | ||
name="search" | ||
/> | ||
</function> | ||
<function model="stock.inventory" name="action_validate"> | ||
<function | ||
eval="[[('state','=','confirm'),('id', '=', ref('stock_account_inventory_lp'))]]" | ||
model="stock.inventory" | ||
name="search" | ||
/> | ||
</function> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import common | ||
from . import test_invoicing_picking | ||
from . import test_stock_rule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Copyright (C) 2023-Today - Akretion (<http://www.akretion.com>). | ||
# @author Magno Costa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.tests.common import Form, TransactionCase | ||
|
||
|
||
class TestBrPickingInvoicingCommon(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
|
||
def _change_user_company(self, company): | ||
self.env.user.company_ids += company | ||
self.env.user.company_id = company | ||
|
||
def _run_fiscal_onchanges(self, record): | ||
record._onchange_fiscal_operation_id() | ||
|
||
def _run_fiscal_line_onchanges(self, record): | ||
# Mixin Fiscal | ||
record._onchange_commercial_quantity() | ||
|
||
# Stock Move | ||
record._onchange_product_id_fiscal() | ||
record._onchange_fiscal_operation_id() | ||
record._onchange_fiscal_operation_line_id() | ||
record._onchange_fiscal_taxes() | ||
record._onchange_product_quantity() | ||
|
||
def picking_move_state(self, picking): | ||
self._run_fiscal_onchanges(picking) | ||
picking.action_confirm() | ||
# Check product availability | ||
picking.action_assign() | ||
# Force product availability | ||
for move in picking.move_ids_without_package: | ||
self._run_fiscal_line_onchanges(move) | ||
move.quantity_done = move.product_uom_qty | ||
picking.button_validate() | ||
|
||
def create_invoice_wizard(self, pickings): | ||
wizard_obj = self.env["stock.invoice.onshipping"].with_context( | ||
active_ids=pickings.ids, | ||
active_model=pickings._name, | ||
) | ||
fields_list = wizard_obj.fields_get().keys() | ||
wizard_values = wizard_obj.default_get(fields_list) | ||
# One invoice per partner but group products | ||
wizard_values.update({"group": "partner_product"}) | ||
wizard = wizard_obj.create(wizard_values) | ||
wizard.onchange_group() | ||
wizard.action_generate() | ||
domain = [("picking_ids", "in", pickings.ids)] | ||
invoice = self.env["account.move"].search(domain) | ||
return invoice | ||
|
||
def return_picking_wizard(self, picking): | ||
# Return Picking | ||
return_wizard_form = Form( | ||
self.env["stock.return.picking"].with_context( | ||
**dict(active_id=picking.id, active_model="stock.picking") | ||
) | ||
) | ||
return_wizard_form.invoice_state = "2binvoiced" | ||
self.return_wizard = return_wizard_form.save() | ||
|
||
result_wizard = self.return_wizard.create_returns() | ||
self.assertTrue(result_wizard, "Create returns wizard fail.") | ||
picking_devolution = self.env["stock.picking"].browse( | ||
result_wizard.get("res_id") | ||
) | ||
return picking_devolution | ||
|
||
def create_backorder_wizard(self, picking): | ||
res_dict_for_back_order = picking.button_validate() | ||
backorder_wizard = Form( | ||
self.env[res_dict_for_back_order["res_model"]].with_context( | ||
**res_dict_for_back_order["context"] | ||
) | ||
).save() | ||
backorder_wizard.process() | ||
backorder = self.env["stock.picking"].search( | ||
[("backorder_id", "=", picking.id)] | ||
) | ||
return backorder |
Oops, something went wrong.