Skip to content

Commit

Permalink
[9.0][PORT] purchase_analytic_global
Browse files Browse the repository at this point in the history
  • Loading branch information
yvaucher committed Dec 16, 2019
1 parent 875bee3 commit e5d4b04
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 134 deletions.
55 changes: 55 additions & 0 deletions purchase_analytic_global/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

==================================
Purchase - Analytic Account Global
==================================

This module adds an analytic account on the purchases that is applied on all the lines.


Usage
=====

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


Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/purchase-workflow/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.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
23 changes: 1 addition & 22 deletions purchase_analytic_global/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
# Copyright 2014 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import purchase
from . import models
37 changes: 6 additions & 31 deletions purchase_analytic_global/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,18 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
# Copyright 2014 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

# © 2014-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{'name': 'Purchase - Analytic Account Global',
'version': '1.0',
'author': 'Camptocamp',
'version': '9.0.1.0.0',
'author': 'Camptocamp, Odoo Community Association (OCA)',
'maintainer': 'Camptocamp',
'license': 'AGPL-3',
'category': 'Purchase Management',
'complexity': "easy",
'depends': ['purchase',
],
'description': """
Purchase - Analytic Account Global
==================================
Adds an analytic account on the purchases that is applied on all the lines.
""",
'website': 'http://www.camptocamp.com',
'data': ['purchase_view.xml',
'website': 'https://github.com/OCA/purchase-workflow',
'data': ['views/purchase.xml',
],
'test': [],
'installable': True,
'auto_install': False,
}
1 change: 1 addition & 0 deletions purchase_analytic_global/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import purchase
26 changes: 26 additions & 0 deletions purchase_analytic_global/models/purchase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from openerp import api, fields, models


class PurchaseOrder(models.Model):
_inherit = 'purchase.order'

account_analytic_id = fields.Many2one(
'account.analytic.account',
string='Analytic Account',
states={'confirmed': [('readonly', True)],
'approved': [('readonly', True)],
'done': [('readonly', True)]},
help="The analytic account that will be set on all the lines. "
"If you want to use different accounts, leave this field "
"empty and set the accounts individually on the lines.")

@api.onchange('account_analytic_id')
def onchange_default_analytic_id(self):
if not self.order_line:
return
for line in self.order_line:
line.account_analytic_id = self.account_analytic_id
58 changes: 0 additions & 58 deletions purchase_analytic_global/purchase.py

This file was deleted.

23 changes: 0 additions & 23 deletions purchase_analytic_global/purchase_view.xml

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions purchase_analytic_global/views/purchase.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="purchase_order_form" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_ref']" position="after">
<field name="account_analytic_id"
groups="purchase.group_analytic_accounting"
domain="[('account_type','=','normal')]"
/>
</xpath>
<field name="order_line" position="attributes">
<attribute name="context">{'default_account_analytic_id': account_analytic_id}</attribute>
</field>
</field>
</record>

</odoo>

0 comments on commit e5d4b04

Please sign in to comment.