Stefan Becker
7 years ago
6 changed files with 192 additions and 0 deletions
-
63contract_purchase/README.rst
-
2contract_purchase/__init__.py
-
19contract_purchase/__openerp__.py
-
2contract_purchase/models/__init__.py
-
68contract_purchase/models/account.py
-
38contract_purchase/views/contract_view.xml
@ -0,0 +1,63 @@ |
|||||
|
.. 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 |
||||
|
|
||||
|
================= |
||||
|
Contract Purchase |
||||
|
================= |
||||
|
|
||||
|
This module is an add on to the odoo contract module (v9). It applies contract functions for purchases. |
||||
|
|
||||
|
Usage |
||||
|
===== |
||||
|
|
||||
|
To use this module, you need to: |
||||
|
|
||||
|
#. Go to Purchases -> Contracts and select or create a new contract. |
||||
|
#. Define type purchase contract |
||||
|
|
||||
|
------------------from here on everything applies like in the contract module------------------ |
||||
|
|
||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
||||
|
:alt: Try me on Runbot |
||||
|
:target: https://runbot.odoo-community.org/runbot/110/9.0 |
||||
|
|
||||
|
For further information, please visit: |
||||
|
|
||||
|
* https://www.odoo.com/forum/help-1 |
||||
|
|
||||
|
Known issues / Roadmap |
||||
|
====================== |
||||
|
PLACEHOLDER |
||||
|
|
||||
|
Bug Tracker |
||||
|
=========== |
||||
|
|
||||
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/contract/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 |
||||
|
`here <https://github.com/OCA/contract/issues/new?body=module:%20contract_purchase%0Aversion:%209.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Stefan Becker <s.becker@humanilog.org> |
||||
|
|
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: http://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: http://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 http://odoo-community.org. |
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from . import models |
@ -0,0 +1,19 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © Stefan Becker <s.becker@humanilog.org> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
{ |
||||
|
'name': 'Purchase Contract', |
||||
|
'summary': 'Create purchase contract', |
||||
|
'version': '9.0.1.0.0', |
||||
|
'author': "humanilog, " |
||||
|
"Odoo Community Association (OCA)", |
||||
|
'website': 'http://www.humanilog.org/', |
||||
|
'depends': ['contract', 'purchase'], |
||||
|
'category': 'Purchase Management', |
||||
|
'license': 'AGPL-3', |
||||
|
'data': [ |
||||
|
'views/contract_view.xml', |
||||
|
], |
||||
|
'installable': True, |
||||
|
} |
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from . import account |
@ -0,0 +1,68 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2015 Angel Moya <angel.moya@domatix.com> |
||||
|
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from openerp import api, fields, models, _ |
||||
|
|
||||
|
|
||||
|
class AccountAnalyticAccount(models.Model): |
||||
|
_inherit = 'account.analytic.account' |
||||
|
|
||||
|
type = fields.Selection(selection_add=[ |
||||
|
('purchase', _('Purchase')) |
||||
|
]) |
||||
|
|
||||
|
@api.multi |
||||
|
def _prepare_invoice(self): |
||||
|
self.ensure_one() |
||||
|
|
||||
|
if self.type == 'purchase': |
||||
|
journal = self.env['account.journal'].search([ |
||||
|
('type', '=', 'purchase'), |
||||
|
('company_id', '=', self.company_id.id) |
||||
|
], limit=1) |
||||
|
|
||||
|
res = super( |
||||
|
AccountAnalyticAccount, |
||||
|
self.with_context( |
||||
|
contract_journal=journal |
||||
|
) |
||||
|
)._prepare_invoice() |
||||
|
|
||||
|
res.update({ |
||||
|
'journal_id': journal.id, |
||||
|
'type': 'in_invoice' |
||||
|
}) |
||||
|
|
||||
|
return res |
||||
|
else: |
||||
|
return super(AccountAnalyticAccount, self)._prepare_invoice() |
||||
|
|
||||
|
return res |
||||
|
|
||||
|
def fields_get( |
||||
|
self, cr, user, allfields=None, context=None, write_access=True, |
||||
|
attributes=None |
||||
|
): |
||||
|
if not context: |
||||
|
context = {} |
||||
|
|
||||
|
res = super(AccountAnalyticAccount, self).fields_get( |
||||
|
cr, user, allfields, context, write_access, attributes) |
||||
|
if all(( |
||||
|
'partner_id' in res, |
||||
|
context.get('default_type') == 'contract_purchase' |
||||
|
)): |
||||
|
res['partner_id']['string'] = _("Vendor") |
||||
|
return res |
||||
|
|
||||
|
@api.onchange('type') |
||||
|
def onchange_type(self): |
||||
|
if self.type == 'purchase': |
||||
|
self.journal_id = self.env['account.journal'].search([ |
||||
|
('type', '=', 'purchase'), |
||||
|
('company_id', '=', self.company_id.id) |
||||
|
], limit=1) |
||||
|
|
||||
|
super(AccountAnalyticAccount, self)._onchange_type() |
@ -0,0 +1,38 @@ |
|||||
|
<?xml version="1.0"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
<record id="account_analytic_account_type" model="ir.ui.view"> |
||||
|
<field name="name">account.analytic.account.type</field> |
||||
|
<field name="model">account.analytic.account</field> |
||||
|
<field name="inherit_id" ref="analytic.view_account_analytic_account_form" /> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr='//field[@name="code"]' position='before'> |
||||
|
<field name="type"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_account_analytic_purchase_overdue_all" model="ir.actions.act_window"> |
||||
|
<field name="name">Contracts</field> |
||||
|
<field name="res_model">account.analytic.account</field> |
||||
|
<field name="view_type">form</field> |
||||
|
<field name="view_mode">tree,form</field> |
||||
|
<field name="domain">[('type', '=', 'purchase')]</field> |
||||
|
<field name="context">{ |
||||
|
'search_default_active':1, |
||||
|
'search_default_recurring_invoices':1, |
||||
|
'default_type': 'purchase' |
||||
|
}</field> |
||||
|
<!--<field name="search_view_id" ref="analytic.view_account_analytic_account_search"/>--> |
||||
|
<field name="help" type="html"> |
||||
|
<p class="oe_view_nocontent_create"> |
||||
|
Click to create a new purchase contract. |
||||
|
</p> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<menuitem action="action_account_analytic_purchase_overdue_all" |
||||
|
id="menu_action_account_analytic_purchase_overdue_all" sequence="8" |
||||
|
parent="purchase.menu_procurement_management"/> |
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue