add fields 'last_order' and 'last_order_date' to res_partner
parent
8868ce6746
commit
2e0921dd86
|
|
@ -0,0 +1,8 @@
|
||||||
|
###################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 2018-Today TZAustria
|
||||||
|
# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses).
|
||||||
|
#
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
from . import models
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
###################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 2018-Today TZAustria
|
||||||
|
# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses).
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Last Order (Offer)",
|
||||||
|
"summary": """Adds Last order date""",
|
||||||
|
'version': '11.0.1.0.0',
|
||||||
|
'author': 'TZAustria',
|
||||||
|
'support': 'andreas.osim@glaser-co.at',
|
||||||
|
'website': 'https://www.tzaustria.at',
|
||||||
|
'depends': ['base','crm'],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
'depends': ['base','account','dp_custom',],
|
||||||
|
"data": [
|
||||||
|
"views/res_partner_view.xml",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
###################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 2020-Today TZAustria
|
||||||
|
# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses).
|
||||||
|
#
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
from . import res_partner
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from odoo import fields, models, api
|
||||||
|
|
||||||
|
class ResPartner(models.Model):
|
||||||
|
_inherit = "res.partner"
|
||||||
|
|
||||||
|
last_order = fields.Char(string="Letzter Auftrag", readonly=True, compute="get_last_order", store=True, copy=False)
|
||||||
|
last_order_date = fields.Date(string="Letztes Auftragsdatum", readonly=True, compute="get_last_order", store=True, copy=False)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def get_last_order(self):
|
||||||
|
for partner in self:
|
||||||
|
order_ids = self.env['sale.order'].search([('partner_id', '=', partner.id),
|
||||||
|
('state', 'not in', ['cancel'])])
|
||||||
|
order = order_ids and max(order_ids)
|
||||||
|
if order:
|
||||||
|
partner.last_order = order.name
|
||||||
|
partner.last_order_date = order.date_order
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="res_partner_form_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">res.partner.form.inherit</field>
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='retail_partner_id']" position="after">
|
||||||
|
<label for="last_order"/>
|
||||||
|
<div class="o_row" name="order_group">
|
||||||
|
<field name="last_order"/>
|
||||||
|
<field name="last_order_date"/>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in New Issue