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 authored and sonhd committed Dec 27, 2021
1 parent b072977 commit b0ce83a
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 112 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 <[email protected]>
* Yannick Vaucher <[email protected]>

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
34 changes: 5 additions & 29 deletions purchase_analytic_global/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,17 @@
# -*- 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',
'data': ['views/purchase.xml',
],
'test': [],
'installable': True,
Expand Down
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.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/group/group/field[@name='pricelist_id']" position="after">
<xpath expr="//field[@name='partner_ref']" position="after">
<field name="account_analytic_id"
groups="purchase.group_analytic_accounting"
on_change="onchange_default_analytic_id(account_analytic_id, order_line)"
domain="[('type','not in',('view','template'))]"
domain="[('account_type','=','normal')]"
/>
</xpath>
<field name="order_line" position="attributes">
Expand Down

0 comments on commit b0ce83a

Please sign in to comment.