new module sale.cart - Overview of shopping carts over assigned companies

develop
Andreas Osim 2021-04-08 12:16:13 +02:00
parent 63254bed24
commit fa91f48fc7
5 changed files with 361 additions and 12 deletions

View File

@ -18,6 +18,162 @@ msgstr ""
"X-Launchpad-Export-Date: 2014-09-24 09:44+0000\n"
"X-Generator: Launchpad (build 17196)\n"
#. module: dp_custom
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "Quotation / Order"
msgstr "Angebot / Auftrag"
#. module: dp_custom
#: model:ir.actions.act_window,name:dp_custom.action_carts
#: model:ir.ui.menu,name:dp_custom.menu_sale_carts
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "Shopping Cart"
msgstr "Warenkorb"
#. module: dp_custom
#: model:ir.actions.act_window,name:dp_custom.action_carts
#: model:ir.ui.menu,name:dp_custom.menu_sale_carts
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "Shopping Carts"
msgstr "Warenkörbe"
#. module: dp_custom
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "Customer Reference"
msgstr "Kundenreferenz"
#. module: dp_custom
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "Customer"
msgstr "Kunde"
#. module: dp_custom
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "Company"
msgstr "Firma"
#. module: dp_custom
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "State"
msgstr "Status"
#. module: dp_custom
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "State PG"
msgstr "Status PG"
#. module: dp_custom
#: model:ir.ui.view,arch_db:dp_custom.view_sale_cart
#: model:ir.ui.view,arch_db:dp_custom.view_cart_tree
msgid "Quotation Date"
msgstr "Angebotsdatum"
#. module: dp_custom
#: selection:sale.cart,state:0
msgid "Quotation Sent"
msgstr "Angebot gesendet"
#. module: dp_custom
#: selection:sale.cart,state:0
msgid "Quotation"
msgstr "Angebot"
#. module: dp_custom
#: selection:sale.cart,state:0
msgid "Sales Order"
msgstr "Verkaufsauftrag"
#. module: dp_custom
#: selection:sale.cart,state:0
msgid "Done"
msgstr "Fertig"
#. module: dp_custom
#: selection:sale.cart,state:0
msgid "Cancelled"
msgstr "Abgebrochen"
#. module: dp_custom
#: selection:sale.cart,state:0
msgid "Cancelled"
msgstr "Abgebrochen"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Imported"
msgstr "Import"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Error Import"
msgstr "Fehler Import"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Not Released"
msgstr "nicht freigegeben"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Released for Production"
msgstr "Produktionsfreigabe"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Released"
msgstr "Freigegeben"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Error Release"
msgstr "Fehler Freigabe"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Production Started"
msgstr "Produktion Begonnen"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Production Finished"
msgstr "Produktion Fertig"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Packed"
msgstr "Verpackt"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Delivered"
msgstr "Geliefert"
#. module: dp_custom
#: selection:sale.cart,assembly_state:0
#: selection:sale.order,assembly_state:0
msgid "Completed"
msgstr "Abgeschlossen"
#. module: dp_custom
#: model:ir.actions.act_window,help:dp_custom.action_partner_form
msgid "Click to add a contact in your address book."

View File

@ -26,25 +26,82 @@ from odoo.exceptions import ValidationError, UserError, Warning
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.tools import float_compare
from odoo.tools import float_is_zero
from odoo.tools import drop_view_if_exists
from dateutil.relativedelta import relativedelta
import dateutil.parser
class SaleCart(models.Model):
_name = 'sale.cart'
_auto = False
ASSEMBLY_STATES = [('import', 'Imported'),
('import_failed', 'Error Import'),
('created', 'Not Released'),
('approved', 'Released for Production'),
('wait', 'Released'),
('failed', 'Error Release'),
('started', 'Production Started'),
('done', 'Production Finished'),
('packed', 'Packed'),
('delivered', 'Delivered'),
('completed', 'Completed')]
order_states = [
('draft', 'Quotation'),
('sent', 'Quotation Sent'),
('sale', 'Sales Order'),
('done', 'Done'),
('cancel', 'Cancelled')]
order_id = fields.Many2one('sale.order', string = 'Quotation / Order')
origin = fields.Char(string='Shopping Cart')
client_order_ref = fields.Char(string='Customer Reference')
name = fields.Char(string='Quotation')
date_order = fields.Date(string='Quotation Date:')
partner_id = fields.Many2one('res.partner', string = 'Customer')
company_id = fields.Many2one('res.company', string = 'Company')
user_id = fields.Many2one('res.users', string = 'User')
assembly_state = fields.Selection(ASSEMBLY_STATES, string="State PG")
state = fields.Selection(order_states, string="State")
@api.model_cr
def init(self):
# print("connected")
drop_view_if_exists(self._cr, 'sale_cart')
self._cr.execute("""CREATE OR REPLACE VIEW sale_cart AS
SELECT DISTINCT row_number() OVER () AS id,
so.id AS order_id,
so.name AS name,
so.origin AS origin,
so.client_order_ref AS client_order_ref,
so.date_order AS date_order,
so.assembly_state AS assembly_state,
so.state AS state,
so.partner_id AS partner_id,
so.company_id AS company_id,
c_u.user_id AS user_id
FROM sale_order so
INNER JOIN res_company_users_rel c_u ON so.company_id = c_u.cid
WHERE so.state != 'cancel' AND so.origin != ''
""")
class SaleOrder(models.Model):
_name = 'sale.order'
_inherit = ['sale.order', 'dp_custom.helper']
ASSEMBLY_STATES = [('import', 'Import'),
('import_failed', 'Fehler Import'),
('created', 'nicht freigegeben'),
('approved', 'Produktionsfreigabe'),
('wait', 'freigegeben'),
('failed', 'Fehler Freigabe'),
('started', 'Produktion begonnen'),
('done', 'Produktion fertig'),
('packed', 'Verpackt'),
('delivered', 'Geliefert'),
('completed', 'Abgeschlossen')]
ASSEMBLY_STATES = [('import', 'Imported'),
('import_failed', 'Error Import'),
('created', 'Not Released'),
('approved', 'Released for Production'),
('wait', 'Released'),
('failed', 'Error Release'),
('started', 'Production Started'),
('done', 'Production Finished'),
('packed', 'Packed'),
('delivered', 'Delivered'),
('completed', 'Completed')]
# ORDER_TYPES = [
# ('M', 'Manuell'),
@ -157,7 +214,7 @@ class SaleOrder(models.Model):
if not self.env.user.has_group('dp_custom.group_allow_third_country_sale'):
if record.partner_invoice_id.country_id != record.partner_shipping_id.country_id:
message = _('Rechnungs- und Lieferland passen nicht zusammen: %s <-> %s!') % \
(record.partner_invoice_id.country_id, record.partner_shipping_id.country_id)
(record.partner_invoice_id.country_id.name, record.partner_shipping_id.country_id.name)
raise Warning(_(message))

View File

@ -12,3 +12,4 @@ access_sale_order_unlink,sale.order.unlink,model_sale_order,dp_custom.group_allo
access_commission_account_user,access_commission_account_user,model_commission_account,base.group_user,1,0,0,0
access_commission_account_manager,access_commission_account_manager,model_commission_account,sales_team.group_sale_manager,1,1,1,1
access_res_confirmation_queue_user,access_res_confirmation_queue_user,model_res_confirmation_queue,base.group_user,1,1,1,1
access_sale_cart,access_sale_cart,model_sale_cart,dp_custom.rule_cart_multi_company,1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
12 access_commission_account_user access_commission_account_user model_commission_account base.group_user 1 0 0 0
13 access_commission_account_manager access_commission_account_manager model_commission_account sales_team.group_sale_manager 1 1 1 1
14 access_res_confirmation_queue_user access_res_confirmation_queue_user model_res_confirmation_queue base.group_user 1 1 1 1
15 access_sale_cart access_sale_cart model_sale_cart dp_custom.rule_cart_multi_company 1 0 0 0

View File

@ -28,4 +28,24 @@
<field name="name">Ändern des Flags 'Preisliste im Portal verwaltet' erlauben</field>
<field name="comment">Ändern des Flags 'Preisliste im Portal verwaltet' erlauben</field>
</record>
<record id="group_allow_third_country_sale" model="res.groups">
<field name="name">Darf in Drittländer-Lieferungen einstellen</field>
<field name="comment">Darf in Drittländer-Lieferungen einstellen (Land in Rechnungsadresse &lt;&gt; Land in Lieferadresse)</field>
</record>
<record id="rule_cart_multi_company" model="res.groups">
<field name="name">Shopping Cart multi-company</field>
<field name="comment">Allows Listing of Shopping Carts in allowed multi-companies</field>
<!--
<field name="model_id" ref="model_sale_cart"/>
<field name="groups" eval="[(4,ref('base.group_multi_company'))]"/>
<field name="global" eval="True"/>
<field name="domain_force">[(1,'=',1)]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
-->
</record>
</odoo>

View File

@ -269,4 +269,119 @@
</field>
</record>
<record id="sale_cart_view_search" model="ir.ui.view">
<field name="name">sale.cart.search</field>
<field name="model">sale.cart</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<search string="Warenkörbe">
<field name="name" string="Sales Order" filter_domain="['|','|','|',('name','ilike',self),
('origin','ilike',self),('client_order_ref','ilike',self),('partner_id','child_of',self)]"/>
<filter string="Quotations" name="draft" domain="[('state','=','draft')]"/>
<filter string="Quotations Sent" name="sent" domain="[('state','=','sent')]"/>
<filter string="Sales" name="sales" domain="[('state','in',('sale','done'))]"/>
</search>
</field>
</record>
<record id="action_carts" model="ir.actions.act_window">
<field name="name">Shopping Cart</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.cart</field>
<field name="view_type">form</field>
<field name="view_id" ref="dp_custom.view_cart_tree"/>
<field name="view_mode">tree,kanban,form</field>
<field name="search_view_id" ref="sale_cart_view_search"/>
<field name="domain">[('user_id','=',uid)]</field>
</record>
<record id="view_cart_tree" model="ir.ui.view">
<field name="name">sale_cart_tree</field>
<field name="model">sale.cart</field>
<field name="arch" type="xml">
<tree string="Shopping Carts" create="false">
<field name="origin" string="Shopping Cart"/>
<field name="name" string="Quotation / Order"/>
<field name="date_order" string="Quotation Date"/>
<field name="partner_id" string="Customer"/>
<field name="company_id" string="Company"/>
<field name="assembly_state" string="State PG"/>
<field name="state" string="State"/>
<field name="user_id" invisible="1"/>
</tree>
</field>
</record>
<record id="view_sale_cart" model="ir.ui.view">
<field name="name">view_sale_cart</field>
<field name="model">sale.cart</field>
<field name="arch" type="xml">
<form string="Shopping Cart">
<group>
<field name="order_id" string="Quotation / Order"/>
<!--
<field name="name" string="Quotation Number"/>
-->
<field name="origin" string="Shopping Cart"/>
<field name="client_order_ref" string="Customer Reference"/>
<field name="date_order" string="Quotation Date"/>
<field name="partner_id" string="Customer" options="{'no_open':True}"/>
<field name="company_id" string="Company" options="{'no_open':True}"/>
<field name="state" string="State" options="{'no_open':True}"/>
<field name="assembly_state" string="State PG" options="{'no_open':[('company_id','!=',1)]}"/>
<field name="user_id" invisible="1"/>
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_sale_cart_kanban">
<field name="name">sale.cart.kanban</field>
<field name="model">sale.cart</field>
<field name="arch" type="xml">
<kanban class="o_kanban_mobile">
<field name="origin"/>
<field name="name"/>
<field name="client_order_ref"/>
<field name="date_order"/>
<field name="partner_id"/>
<field name="company_id"/>
<field name="state"/>
<field name="assembly_state"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card oe_kanban_global_click">
<div class="o_kanban_record_top mb16">
<div class="o_kanban_record_headings mt4">
<strong class="o_kanban_record_title"><span><t t-esc="record.partner_id.value"/></span></strong>
</div>
<strong><field name="origin"/></strong>
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left text-muted">
<span><t t-esc="record.name.value"/> <t t-esc="record.date_order.value"/></span>
</div>
<div class="oe_kanban_bottom_right">
<field name="state" widget="label_selection" options="{'classes': {'draft': 'default', 'cancel': 'default', 'done': 'success'}}"/>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<menuitem id="menu_sale_carts"
name = "Shopping Carts"
action="action_carts"
parent="sale.sale_order_menu"
sequence="30"
/>
</odoo>