Skip to content

Commit

Permalink
[MIG][9.0] stock_analytic
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow committed Jun 12, 2017
1 parent 227c9f8 commit 682ca6e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 67 deletions.
18 changes: 4 additions & 14 deletions stock_analytic/README.rst
Expand Up @@ -9,22 +9,11 @@ Stock Analytic
Adds an analytic account in stock move to be able to get analytic information
when generating the journal items.

Installation
============

To install this module, you need to:

1. Clone the branch 8.0 of the repository https://github.com/OCA/account-analytic
2. Add the path to this repository in your configuration (addons-path)
3. Update the module list
4. Go to menu *Setting -> Modules -> Local Modules*
5. Search For *Stock Analytic*
6. Install the module

Usage
=====

Assigned Stock Move With Analytic Account
To Assign an Analytic Account to a Stock Move
-----------------------------------------

You need to:
Expand All @@ -46,7 +35,7 @@ journal items with following rule:

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/87/8.0
:target: https://runbot.odoo-community.org/runbot/87/9.0

Bug Tracker
===========
Expand All @@ -68,7 +57,8 @@ Contributors
* Mathieu VATEL <mathieu@julius.fr>
* Fabio Vílchez <fabio.vilchez@clearcorp.co.cr>
* Andhitia Rama <andhitia.r@gmail.com>
* Michael Viriyananda <viriyananda.michael@gmai.com>
* Michael Viriyananda <viriyananda.michael@gmail.com>
* Eficent <contact@eficent.com>

Maintainer
----------
Expand Down
7 changes: 3 additions & 4 deletions stock_analytic/__openerp__.py
Expand Up @@ -6,10 +6,10 @@
{
"name": "Stock Analytic",
"summary": "Adds an analytic account in stock move",
"version": "8.0.1.0.0",
"version": "9.0.1.0.0",
"author": "Julius Network Solutions,"
"ClearCorp, OpenSynergy Indonesia, "
"Odoo Community Association (OCA)",
"ClearCorp, OpenSynergy Indonesia,"
"Odoo Community Association (OCA)",
"website": "http://www.julius.fr/",
"category": "Warehouse Management",
"license": "AGPL-3",
Expand All @@ -22,5 +22,4 @@
"views/stock_inventory_views.xml",
],
'installable': True,
'active': False,
}
13 changes: 3 additions & 10 deletions stock_analytic/models/stock.py
Expand Up @@ -22,16 +22,9 @@ class StockQuant(models.Model):

@api.model
def _prepare_account_move_line(self, move, qty, cost,
credit_account_id, debit_account_id,
context=None):
res = super(StockQuant,
self)._prepare_account_move_line(
move, qty, cost,
credit_account_id,
debit_account_id,
context=context
)

credit_account_id, debit_account_id):
res = super(StockQuant, self)._prepare_account_move_line(
move, qty, cost, credit_account_id, debit_account_id)
# Add analytic account in debit line
if not move.analytic_account_id:
return res
Expand Down
22 changes: 9 additions & 13 deletions stock_analytic/tests/test_stock_picking.py
Expand Up @@ -15,27 +15,22 @@ def setUp(self):

self.product = self.env.ref('product.product_product_4')
self.product.update({'valuation': 'real_time'})
self.product_categ = self.env.ref('product.ipad')
self.valuation_account = self.env.ref('account.stk')
self.stock_account = self.env.ref('account.xfa')
self.stock_journal = self.env.ref('stock_account.stock_journal')
self.analytic_journal = self.env.ref('account.sit')
self.product_categ = self.env.ref('product.product_category_5')
self.valuation_account = self.env.ref(
'account.data_account_type_expenses')
self.stock_account = self.env.ref('account.data_account_type_revenue')
self.analytic_account = self.env.ref(
'account.analytic_project_1_development')
'analytic.analytic_agrolait')
self.warehouse = self.env.ref('stock.warehouse0')
self.location = self.warehouse.lot_stock_id
self.dest_location = self.env.ref('stock.stock_location_customers')
self.outgoing_picking_type = self.env.ref('stock.picking_type_out')
self.incoming_picking_type = self.env.ref('stock.picking_type_in')

self.stock_journal.update({
'analytic_journal_id': self.analytic_journal.id
})

self.product_categ.update({
'property_stock_valuation_account_id': self.valuation_account.id,
'property_stock_account_input_categ': self.stock_account.id,
'property_stock_account_output_categ': self.stock_account.id,
'property_stock_account_input_categ_id': self.stock_account.id,
'property_stock_account_output_categ_id': self.stock_account.id,
})

def _create_picking(
Expand All @@ -44,6 +39,8 @@ def _create_picking(
picking_data = {
'picking_type_id': picking_type_id.id,
'move_type': 'direct',
'location_id': location_id.id,
'location_dest_id': location_dest_id.id,
}

picking = self.env['stock.picking'].create(picking_data)
Expand All @@ -55,7 +52,6 @@ def _create_picking(
'location_dest_id': location_dest_id.id,
'date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'date_expected': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'invoice_state': 'none',
'name': self.product.name,
'procure_method': 'make_to_stock',
'product_uom': self.product.uom_id.id,
Expand Down
4 changes: 2 additions & 2 deletions stock_analytic/views/stock_inventory_views.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data>
<record id="view_inventory_form" model="ir.ui.view">
<field name="name">stock.inventory.form</field>
Expand All @@ -12,4 +12,4 @@
</field>
</record>
</data>
</openerp>
</odoo>
26 changes: 2 additions & 24 deletions stock_analytic/views/stock_move_views.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data>
<record id="view_move_picking_form" model="ir.ui.view">
<field name="name">stock.move.picking.form</field>
Expand Down Expand Up @@ -44,28 +44,6 @@
</field>
</record>

<record id="view_move_tree_receipt_picking" model="ir.ui.view">
<field name="name">stock.move.tree2</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_tree_receipt_picking"/>
<field name="arch" type="xml">
<field name='date' position="before">
<field name="analytic_account_id"/>
</field>
</field>
</record>

<record id="view_move_tree_receipt_picking_board" model="ir.ui.view">
<field name="name">stock.move.tree3</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_tree_receipt_picking_board"/>
<field name="arch" type="xml">
<field name='date' position="before">
<field name="analytic_account_id"/>
</field>
</field>
</record>

<record id="view_move_form" model="ir.ui.view">
<field name="name">stock.move.form</field>
<field name="model">stock.move</field>
Expand All @@ -77,4 +55,4 @@
</field>
</record>
</data>
</openerp>
</odoo>

0 comments on commit 682ca6e

Please sign in to comment.