start for quote alternative
This commit is contained in:
parent
9dda5851a3
commit
866f650ffe
14 changed files with 324 additions and 0 deletions
4
bemade_quotation_alternative/__init__.py
Normal file
4
bemade_quotation_alternative/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import wizard
|
||||
from . import models
|
||||
37
bemade_quotation_alternative/__manifest__.py
Normal file
37
bemade_quotation_alternative/__manifest__.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': "Create Quotation Alternative",
|
||||
|
||||
'summary': """
|
||||
Short (1 phrase/line) summary of the module's purpose, used as
|
||||
subtitle on modules listing or apps.openerp.com""",
|
||||
|
||||
'description': """
|
||||
Long description of module's purpose
|
||||
""",
|
||||
|
||||
'author': "Bemade.org",
|
||||
'website': "https://odoo.bemade.org",
|
||||
'license': 'LGPL-3',
|
||||
# Categories can be used to filter modules in modules listing
|
||||
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
|
||||
# for the full list
|
||||
'category': 'Uncategorized',
|
||||
'version': '0.1',
|
||||
|
||||
# any module necessary for this one to work correctly
|
||||
'depends': [
|
||||
'sale_management'
|
||||
],
|
||||
|
||||
# always loaded
|
||||
'data': [
|
||||
# 'security/ir.model.access.csv',
|
||||
'views/sale_order_views.xml',
|
||||
'wizard/sale_order_alternative_views.xml',
|
||||
],
|
||||
# only loaded in demonstration mode
|
||||
'demo': [
|
||||
# 'demo/demo.xml',
|
||||
],
|
||||
}
|
||||
3
bemade_quotation_alternative/controllers/__init__.py
Normal file
3
bemade_quotation_alternative/controllers/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import controllers
|
||||
21
bemade_quotation_alternative/controllers/controllers.py
Normal file
21
bemade_quotation_alternative/controllers/controllers.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# from odoo import http
|
||||
|
||||
|
||||
# class .repos/bemade-addons/bemadeQuotationAlternative(http.Controller):
|
||||
# @http.route('/.repos/bemade-addons/bemade_quotation_alternative/.repos/bemade-addons/bemade_quotation_alternative', auth='public')
|
||||
# def index(self, **kw):
|
||||
# return "Hello, world"
|
||||
|
||||
# @http.route('/.repos/bemade-addons/bemade_quotation_alternative/.repos/bemade-addons/bemade_quotation_alternative/objects', auth='public')
|
||||
# def list(self, **kw):
|
||||
# return http.request.render('.repos/bemade-addons/bemade_quotation_alternative.listing', {
|
||||
# 'root': '/.repos/bemade-addons/bemade_quotation_alternative/.repos/bemade-addons/bemade_quotation_alternative',
|
||||
# 'objects': http.request.env['.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative'].search([]),
|
||||
# })
|
||||
|
||||
# @http.route('/.repos/bemade-addons/bemade_quotation_alternative/.repos/bemade-addons/bemade_quotation_alternative/objects/<model(".repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative"):obj>', auth='public')
|
||||
# def object(self, obj, **kw):
|
||||
# return http.request.render('.repos/bemade-addons/bemade_quotation_alternative.object', {
|
||||
# 'object': obj
|
||||
# })
|
||||
30
bemade_quotation_alternative/demo/demo.xml
Normal file
30
bemade_quotation_alternative/demo/demo.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<odoo>
|
||||
<data>
|
||||
<!--
|
||||
<record id="object0" model=".repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative">
|
||||
<field name="name">Object 0</field>
|
||||
<field name="value">0</field>
|
||||
</record>
|
||||
|
||||
<record id="object1" model=".repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative">
|
||||
<field name="name">Object 1</field>
|
||||
<field name="value">10</field>
|
||||
</record>
|
||||
|
||||
<record id="object2" model=".repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative">
|
||||
<field name="name">Object 2</field>
|
||||
<field name="value">20</field>
|
||||
</record>
|
||||
|
||||
<record id="object3" model=".repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative">
|
||||
<field name="name">Object 3</field>
|
||||
<field name="value">30</field>
|
||||
</record>
|
||||
|
||||
<record id="object4" model=".repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative">
|
||||
<field name="name">Object 4</field>
|
||||
<field name="value">40</field>
|
||||
</record>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
3
bemade_quotation_alternative/models/__init__.py
Normal file
3
bemade_quotation_alternative/models/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import sale_order
|
||||
18
bemade_quotation_alternative/models/models.py
Normal file
18
bemade_quotation_alternative/models/models.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# from odoo import models, fields, api
|
||||
|
||||
|
||||
# class .repos/bemade-addons/bemade_quotation_alternative(models.Model):
|
||||
# _name = '.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative'
|
||||
# _description = '.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative'
|
||||
|
||||
# name = fields.Char()
|
||||
# value = fields.Integer()
|
||||
# value2 = fields.Float(compute="_value_pc", store=True)
|
||||
# description = fields.Text()
|
||||
#
|
||||
# @api.depends('value')
|
||||
# def _value_pc(self):
|
||||
# for record in self:
|
||||
# record.value2 = float(record.value) / 100
|
||||
17
bemade_quotation_alternative/models/sale_order.py
Normal file
17
bemade_quotation_alternative/models/sale_order.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from odoo import fields, models, api
|
||||
|
||||
|
||||
class ModelName(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
def action_create_alternative(self):
|
||||
return {
|
||||
'name': 'Create Alternative',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'bemade.quotation.alternative',
|
||||
'view_mode': 'form',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_sale_order_id': self.id,
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_.repos/bemade-addons/bemade_quotation_alternative_.repos/bemade-addons/bemade_quotation_alternative,.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative,model_.repos/bemade-addons/bemade_quotation_alternative_.repos/bemade-addons/bemade_quotation_alternative,base.group_user,1,1,1,1
|
||||
|
58
bemade_quotation_alternative/views/sale_order_views.xml
Normal file
58
bemade_quotation_alternative/views/sale_order_views.xml
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<odoo>
|
||||
<data>
|
||||
<!-- explicit list view definition -->
|
||||
|
||||
<record model="ir.ui.view" id="bemade_quotation_alternative_form">
|
||||
<field name="name">bemade_quotation_alternative form</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<header position="inside">
|
||||
<button name="action_create_alternative" type="object" string="Create Alternative" class="oe_highlight" />
|
||||
</header>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- actions opening views on models -->
|
||||
<!--
|
||||
<record model="ir.actions.act_window" id=".repos/bemade-addons/bemade_quotation_alternative.action_window">
|
||||
<field name="name">.repos/bemade-addons/bemade_quotation_alternative window</field>
|
||||
<field name="res_model">.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- server action to the one above -->
|
||||
<!--
|
||||
<record model="ir.actions.server" id=".repos/bemade-addons/bemade_quotation_alternative.action_server">
|
||||
<field name="name">.repos/bemade-addons/bemade_quotation_alternative server</field>
|
||||
<field name="model_id" ref="model_.repos/bemade-addons/bemade_quotation_alternative_.repos/bemade-addons/bemade_quotation_alternative"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
action = {
|
||||
"type": "ir.actions.act_window",
|
||||
"view_mode": "tree,form",
|
||||
"res_model": model._name,
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- Top menu item -->
|
||||
<!--
|
||||
<menuitem name=".repos/bemade-addons/bemade_quotation_alternative" id=".repos/bemade-addons/bemade_quotation_alternative.menu_root"/>
|
||||
-->
|
||||
<!-- menu categories -->
|
||||
<!--
|
||||
<menuitem name="Menu 1" id=".repos/bemade-addons/bemade_quotation_alternative.menu_1" parent=".repos/bemade-addons/bemade_quotation_alternative.menu_root"/>
|
||||
<menuitem name="Menu 2" id=".repos/bemade-addons/bemade_quotation_alternative.menu_2" parent=".repos/bemade-addons/bemade_quotation_alternative.menu_root"/>
|
||||
-->
|
||||
<!-- actions -->
|
||||
<!--
|
||||
<menuitem name="List" id=".repos/bemade-addons/bemade_quotation_alternative.menu_1_list" parent=".repos/bemade-addons/bemade_quotation_alternative.menu_1"
|
||||
action=".repos/bemade-addons/bemade_quotation_alternative.action_window"/>
|
||||
<menuitem name="Server to list" id=".repos/bemade-addons/bemade_quotation_alternative" parent=".repos/bemade-addons/bemade_quotation_alternative.menu_2"
|
||||
action=".repos/bemade-addons/bemade_quotation_alternative.action_server"/>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
24
bemade_quotation_alternative/views/templates.xml
Normal file
24
bemade_quotation_alternative/views/templates.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<odoo>
|
||||
<data>
|
||||
<!--
|
||||
<template id="listing">
|
||||
<ul>
|
||||
<li t-foreach="objects" t-as="object">
|
||||
<a t-attf-href="#{ root }/objects/#{ object.id }">
|
||||
<t t-esc="object.display_name"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<template id="object">
|
||||
<h1><t t-esc="object.display_name"/></h1>
|
||||
<dl>
|
||||
<t t-foreach="object._fields" t-as="field">
|
||||
<dt><t t-esc="field"/></dt>
|
||||
<dd><t t-esc="object[field]"/></dd>
|
||||
</t>
|
||||
</dl>
|
||||
</template>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
3
bemade_quotation_alternative/wizard/__init__.py
Normal file
3
bemade_quotation_alternative/wizard/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import sale_order_alternative
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
from odoo import fields, models, api
|
||||
import string
|
||||
|
||||
|
||||
class AlternativeQuotation(models.TransientModel):
|
||||
_name = 'sale.order.alternative'
|
||||
_description = 'Quotation Alternative'
|
||||
|
||||
name = fields.Char()
|
||||
original_sale_order_id = fields.Many2one('sale.order')
|
||||
|
||||
clone_all_lines = fields.Boolean('Clone all lines', default=True)
|
||||
origin = fields.Text('Why this alternative ?')
|
||||
internal_note = fields.Text('Internal Note')
|
||||
|
||||
def action_create_alternative(self):
|
||||
name = self.original_sale_order_id.name
|
||||
|
||||
if name and name[-1] not in string.ascii_letters:
|
||||
self.original_sale_order_id.name = name + "A"
|
||||
name = self.name + "B"
|
||||
else:
|
||||
# Assuming 'all_names' is a list of all names
|
||||
# Add a domain to filter names starting with 'name' (less the last letter)
|
||||
all_names = [record.name for record in self.env['sale.order'].search([('name', 'like', name[:-1] + '%')])]
|
||||
if name in all_names:
|
||||
# Get the index of the current name in the list
|
||||
index = all_names.index(name)
|
||||
# If this is not the last name in the list, get the next one
|
||||
if index < len(all_names) - 1:
|
||||
name = all_names[index + 1]
|
||||
else:
|
||||
# If this is the last name, just add 'B' to it
|
||||
name = name + "B"
|
||||
|
||||
new_quot = quot.original_sale_order_id.copy({
|
||||
'name': quot.name,
|
||||
'origin': quot.original_sale_order_id.name,
|
||||
'alternative_sale_order_id': quot.original_sale_order_id.id,
|
||||
'alternative': True,
|
||||
'alternative_origine': quot.origine,
|
||||
'alternative_internal_note': quot.internal_note,
|
||||
|
||||
# # Lines and line based computes
|
||||
# order_line = fields.One2many(
|
||||
# comodel_name='sale.order.alternative.line',
|
||||
# inverse_name='order_id',
|
||||
# string="Order Lines",
|
||||
# copy=True, auto_join=True)
|
||||
#
|
||||
# class AlternativeQuotation(models.TransientModel):
|
||||
# _name = 'sale.order.alternative.line'
|
||||
# # _inherit = 'sale.order.line'
|
||||
# _description = 'Quotation Alternative Line'
|
||||
#
|
||||
# order_id = fields.Many2one(
|
||||
# comodel_name='sale.order.alternative',
|
||||
# string="Alternative Quotation Reference",
|
||||
# required=True, ondelete='cascade', index=True, copy=False)
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="sale_order_alternative_form_view" model="ir.ui.view">
|
||||
<field name="name">bemade_quotation_alternative.sale_order_alternative.form</field>
|
||||
<field name="model">sale.order.alternative</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Alternative Quotation">
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<label for="original_sale_order_id"/>
|
||||
<h1>
|
||||
<field name="original_sale_order_id" placeholder="Original"/>
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="order_line"/>
|
||||
</group>
|
||||
<group>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- <record id="ModelName_act_window" model="ir.actions.act_window">-->
|
||||
<!-- <field name="name">ModelTitle</field>-->
|
||||
<!-- <field name="type">ir.actions.act_window</field>-->
|
||||
<!-- <field name="res_model">ProjectName.ModelName</field>-->
|
||||
<!-- <field name="view_type">form</field>-->
|
||||
<!-- <field name="view_mode">tree,form</field>-->
|
||||
<!-- <field name="help" type="html">-->
|
||||
<!-- <p class="oe_view_nocontent_create">-->
|
||||
<!-- There is no examples click here to add new ModelTitle.-->
|
||||
<!-- </p>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <menuitem name="ModelTitle" id="ModelName_menu" parent="your_root_menu" action="ModelName_act_window"/>-->
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
Loading…
Reference in a new issue