Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Casa Lito
sale_channel
Commits
19d6332f
Commit
19d6332f
authored
9 years ago
by
Sebastian Kennedy
Browse files
Options
Downloads
Patches
Plain Diff
Adaptacion product_template v8
parent
61d053c1
Branches
Branches containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
__openerp__.py
+2
-3
__openerp__.py
product.py
+32
-1
product.py
product_view.xml
+22
-0
product_view.xml
sale_channel.py
+1
-0
sale_channel.py
with
57 additions
and
4 deletions
__openerp__.py
+
2
−
3
View file @
19d6332f
...
...
@@ -27,15 +27,14 @@
"
description
"
:
"""
"""
,
'
website
'
:
'
http://www.e-mips.com.ar
'
,
'
init_xml
'
:
[],
"
depends
"
:
[
"
base
"
,
"
product
"
,
"
sale
"
,
"
account_discount_payment
"
],
'
up
dat
e_xml
'
:
[
'
dat
a
'
:
[
'
sale_channel_view.xml
'
,
'
partner_view.xml
'
,
'
product_view.xml
'
,
'
sale_view.xml
'
,
],
'
demo
_xml
'
:
[],
'
demo
'
:
[],
'
test
'
:
[],
'
installable
'
:
True
,
'
active
'
:
False
,
...
...
This diff is collapsed.
Click to expand it.
product.py
+
32
−
1
View file @
19d6332f
...
...
@@ -54,4 +54,35 @@ class product_product(models.Model):
return
True
product_product
()
class
product_template
(
models
.
Model
):
_name
=
'
product.template
'
_inherit
=
'
product.template
'
sale_channel_ids
=
fields
.
One2many
(
'
sale.channel.product.line
'
,
'
product_id
'
,
'
Sale Channels
'
)
@api.multi
def
button_update_channels
(
self
):
channel_obj
=
self
.
env
[
'
sale.channel
'
]
product_channel_obj
=
self
.
env
[
'
sale.channel.product.line
'
]
# Buscamos todos los sale channels actuales
channel_ids
=
[
channel
.
id
for
channel
in
channel_obj
.
search
([])]
# Obtenemos los sale_channels referenciados por este producto
product_channel_ids
=
self
.
sale_channel_ids
product_channels
=
[
channel
.
channel_id
for
channel
in
product_channel_ids
]
channels_on_product
=
[
p
.
id
for
p
in
product_channels
]
# Obtenemos los canales que todavia no estan en el producto
channels_to_add
=
filter
(
lambda
x
:
x
not
in
channels_on_product
,
channel_ids
)
# Creamos las nuevas lineas de canales de venta para los canales que faltan en ese producto
for
chan_id
in
channels_to_add
:
prod_channel_vals
=
{
'
channel_id
'
:
chan_id
,
'
product_id
'
:
self
.
id
}
product_channel_obj
.
create
(
prod_channel_vals
)
return
True
This diff is collapsed.
Click to expand it.
product_view.xml
+
22
−
0
View file @
19d6332f
...
...
@@ -23,6 +23,28 @@
</page>
</field>
</record>
<record
model=
"ir.ui.view"
id=
"view_product_template_sale_channel_form"
>
<field
name=
"name"
>
product.template.sale.channel.form
</field>
<field
name=
"model"
>
product.template
</field>
<field
name=
"type"
>
form
</field>
<field
name=
"inherit_id"
ref=
"product.product_template_only_form_view"
/>
<field
name=
"arch"
type=
"xml"
>
<page
string=
"Sales"
position=
"after"
>
<page
string=
"Sale Channels"
attrs=
"{'invisible':[('sale_ok','=',False)]}"
>
<field
name=
"sale_channel_ids"
nolabel=
"1"
colspan=
"4"
>
<tree
string=
"Sale Channels"
editable=
"bottom"
>
<field
name=
"channel_id"
readonly=
"1"
/>
<field
name=
"main_percent"
string=
"Main Percent"
/>
<field
name=
"offer_percent"
string=
"Offer Percent"
/>
<field
name=
"variation_percent"
string=
"Variation Percent"
/>
</tree>
</field>
<button
name=
"button_update_channels"
string=
"Update Channels"
type=
"object"
/>
</page>
</page>
</field>
</record>
</data>
</openerp>
This diff is collapsed.
Click to expand it.
sale_channel.py
+
1
−
0
View file @
19d6332f
...
...
@@ -123,6 +123,7 @@ class sale_channel_product_line(models.Model):
main_pricelist_item_id
=
fields
.
Many2one
(
'
product.pricelist.item
'
)
variation_pricelist_item_id
=
fields
.
Many2one
(
'
product.pricelist.item
'
)
offer_pricelist_item_id
=
fields
.
Many2one
(
'
product.pricelist.item
'
)
product_tmpl_id
=
fields
.
Many2one
(
'
product.template
'
,
'
Product
'
)
product_id
=
fields
.
Many2one
(
'
product.product
'
,
'
Product
'
)
@api.model
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets