Merge pull request #256 from wvengen/feature-partial_shared_sync
Small change to allow non-shared articles with shared suppliers
This commit is contained in:
commit
2de4a2a3a0
6 changed files with 16 additions and 2 deletions
|
|
@ -227,6 +227,7 @@ class ArticlesController < ApplicationController
|
|||
if @updated_articles.empty? && @outlisted_articles.empty?
|
||||
redirect_to supplier_articles_path(@supplier), :notice => I18n.t('articles.controller.sync.notice')
|
||||
end
|
||||
@ignored_article_count = @supplier.articles.where(order_number: [nil, '']).count
|
||||
end
|
||||
|
||||
# Updates, deletes articles when sync form is submitted
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class Article < ActiveRecord::Base
|
|||
# false will returned and self.shared_updated_on will be updated
|
||||
def shared_article_changed?
|
||||
# skip early if the timestamp hasn't changed
|
||||
unless self.shared_updated_on == self.shared_article.updated_on
|
||||
unless self.shared_article.nil? or self.shared_updated_on == self.shared_article.updated_on
|
||||
|
||||
# try to convert units
|
||||
# convert supplier's price and unit_quantity into fc-size
|
||||
|
|
@ -106,6 +106,7 @@ class Article < ActiveRecord::Base
|
|||
|
||||
# to get the correspondent shared article
|
||||
def shared_article
|
||||
self.order_number.blank? and return nil
|
||||
@shared_article ||= self.supplier.shared_supplier.shared_articles.find_by_number(self.order_number) rescue nil
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,9 @@ class Supplier < ActiveRecord::Base
|
|||
}
|
||||
updated_articles << [article, unequal_attributes]
|
||||
end
|
||||
else
|
||||
# Articles with no order number can be used to put non-shared articles
|
||||
# in a shared supplier, with sync keeping them.
|
||||
elsif not article.order_number.blank?
|
||||
# article isn't in external database anymore
|
||||
outlisted_articles << article
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
.alert= t '.outlist.alert_used', article: article.name
|
||||
- else
|
||||
%i= t '.outlist.body_skip'
|
||||
- if @ignored_article_count > 0
|
||||
%i= t '.outlist.body_ignored', count: @ignored_article_count
|
||||
%hr/
|
||||
%h2= t '.update.title'
|
||||
%p
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue